public void TestInitialize() { mockRepository = new MockRepository(MockBehavior.Default); mockLogger = mockRepository.Create <ILogger <CustomerService> >(); mockCustomerRepository = mockRepository.Create <ICustomerRepository>(); mockCustomerRepository.Setup(x => x.AddCustomer(It.IsAny <CustomerDetails>())).Returns(MockCustomerData.MockCustomerDetails); mockCustomerRepository.Setup(x => x.CustomerDetailsExists(It.IsAny <int>())).Returns(true); mockCustomerRepository.Setup(x => x.DeleteVehicle(It.IsAny <int>())); mockCustomerRepository.Setup(x => x.GetCustomerDetails()).Returns(Task.FromResult(MockCustomerData.MockCustomerDetailsList())); mockCustomerRepository.Setup(x => x.GetCustomerDetails(It.IsAny <int>())).Returns(Task.FromResult(MockCustomerData.MockCustomerDetails())); mockCustomerRepository.Setup(x => x.UpdateCustomer(MockCustomerData.MockCustomerDetails())); }
public async Task GetCustomerDetailsByID_StateUnderTest_ExpectedBehavior() { // Arrange var unitUnderTest = CreateService(); const int id = 1; string expected = JsonConvert.SerializeObject(MockCustomerData.MockCustomerDetails()); // Act var result = await unitUnderTest.GetCustomerDetails( id); var jsonResult = JsonConvert.SerializeObject(result); // Assert Assert.AreEqual(expected, jsonResult); }
public async Task CreateCustomerDetails_StateUnderTest_ExpectedBehavior() { // Arrange var unitUnderTest = CreateService(); CustomerDetails customerDetails = MockCustomerData.MockCustomerDetails(); // Act var result = await unitUnderTest.CreateCustomerDetails( customerDetails); // Assert if (result.CustomerId != 1) { Assert.Fail(); } }
public async Task UpdateCustomerDetails_StateUnderTest_ExpectedBehavior() { // Arrange var unitUnderTest = CreateService(); const int id = 1; CustomerDetails customerDetails = MockCustomerData.MockCustomerDetails(); string expected = JsonConvert.SerializeObject(MockCustomerData.MockCustomerDetails()); // Act var result = await unitUnderTest.UpdateCustomerDetails( id, customerDetails); // Assert if (!result) { Assert.Fail(); } }