public void CreateFamily_AddNullFamily() { //Arrange. var mockRepo = new Mock <IFamilyRepository>(); var service = new FamilyService(mockRepo.Object); mockRepo.Setup(x => x.Add(It.IsAny <Family>())); //Act. service.CreateAsync(null); //Assert - no assert. }
public void CreateFamily_AddExistingFamily_Pass() { //Arrange. var mockRepo = new Mock <IFamilyRepository>(); var service = new FamilyService(mockRepo.Object); mockRepo.Setup(x => x.Add(It.IsAny <Family>())); //Act. service.CreateAsync(Mock.Of <Family>(c => c.Name == "Wolfs" && c.Id == 15)); //Assert - no assert. }
public void CreateFamily_CheckIf_RepositoryAddMethod_IsCalled_Failed() { //Arange. var repoMock = new Mock <IFamilyRepository>(); repoMock.Setup(c => c.Add(It.IsAny <Family>())); var service = new FamilyService(repoMock.Object); //Act. service.CreateAsync(new Family()); //Assert. repoMock.VerifyAll(); }
public async Task CreateAsync_ValidObjectPassed_ReturnCreatedBusiness() { // Arrange var family = new Family("Some name"); _repositoryMock .Setup(rep => rep.AddAsync(family)) .ReturnsAsync(family); // Act var createdFamily = await _familyService.CreateAsync(family); // Assert Assert.Equal(family.Name, createdFamily.Name); }