This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
import Testing | |
@testable import SwiftTestingExample | |
@Test("Add Two Negative Number") | |
func addTwoNegativeNumber() { | |
let calculator = Calculator() | |
let num1 = -2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program{ | |
static void Main() | |
{ | |
var configurationRoot = new ConfigurationBuilder() | |
.SetBasePath(Directory.GetCurrentDirectory()) | |
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false) | |
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true) | |
.Build(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IJobCommand{ | |
int JobId { get; set; } | |
void Execute(); | |
} | |
public interface QueryJob : IJobCommand{ | |
int JobId { get; set; } = 121; | |
//kısa vadede yapınızı bozmamak için buradan resolve edilebilir. | |
string Namespace { get; set; } = "Resolver"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void MoqFactory() | |
{ | |
MockFactory mockFactory = new MockFactory(MockBehavior.Default); | |
// Setup parameters for mocking | |
mockFactory.CallBase = true; | |
mockFactory.DefaultValue = DefaultValue.Mock; | |
Mock<IValidator> validator = mockFactory.Create<IValidator>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void LinqToMocks() | |
{ | |
//Arrange | |
IValidator mockValidator | |
= Mock.Of<IValidator> | |
( | |
validator => | |
validator.IsValid(It.IsAny<string>()) == true | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mock = new Mock<Sample>(); | |
mock.Protected() | |
.Expect<int>("Execute") | |
.Returns(5); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UberQualityService | |
{ | |
DateTimeService _dateService; | |
public UberQualityService(DateTimeService dateService) | |
{ | |
_dateService = dateService | |
} | |
public async bool SaveCustomer(string data) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UberQualityService | |
{ | |
public async bool SaveCustomer(string data) | |
{ | |
if (data != null) | |
{ | |
var customer = JsonConvert.DeserializeObject<Customer>(data); | |
if(DateTime.Today.DayOfWeek == DayOfWeek.Friday) | |
{ | |
//Database save logic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void SetStatusWhenMultipleCall() | |
{ | |
//Arrange | |
Mock<IValidator> mockValidator | |
= new Mock<IValidator>(); | |
mockValidator.SetupSequence(x => x.IsValid(It.IsAny<string>())) | |
.Returns(true) | |
.Returns(false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void SendMessageToAlertQueueWhenIsValidException() | |
{ | |
//Arrange | |
Mock<IValidator> mockValidator | |
= new Mock<IValidator>(); | |
mockValidator.Setup(x => x.ServiceStatus).Returns(Status.NotOK); | |
mockValidator.Setup(x => x.IsValid(It.IsAny<string>())) | |
.Throws(new Exception("Some exception Message")) |
NewerOlder