public async Task ShouldCreateProfile() { Guid profileId = Guid.NewGuid(); _profilesRepoMock .Setup(x => x.GetProfiles()) .ReturnsAsync(new List <Profile>()) .Verifiable(); var profile = new Profile { Id = profileId, ProfileName = "test2", FaceApiConfig = new CognitiveServiceConfig { BaseUrl = "http://url", Token = "token" } }; var handler = new SaveProfileCommand.Handler(_profilesRepoMock.Object); await handler.Handle(new SaveProfileCommand(profile), default); _profilesRepoMock.Verify(); _profilesRepoMock .Verify(x => x.SaveProfiles( It.Is <List <Profile> >(list => list.Count == 1 && list[0].Id != Guid.Empty)), Times.Once()); }
public async Task ShouldUpdateProfile() { Guid profileId = Guid.NewGuid(); _profilesRepoMock .Setup(x => x.GetProfiles()) .ReturnsAsync(new List <Profile> { new Profile("test1") { IsSelected = true }, new Profile("test2") { Id = profileId }, new Profile("test3") }) .Verifiable(); var profile = new Profile { Id = profileId, ProfileName = "test2", FaceApiConfig = new CognitiveServiceConfig { BaseUrl = "http://url", Token = "token" } }; var handler = new SaveProfileCommand.Handler(_profilesRepoMock.Object); await handler.Handle(new SaveProfileCommand(profile), default); _profilesRepoMock.Verify(); _profilesRepoMock .Verify(x => x.SaveProfiles( It.Is <List <Profile> >(list => VerifyProfileIsUpdated(list, profile))), Times.Once()); }