private Song GetReviewerChainInstances(Article article, Blog sharedBlog, Person sharedBlogAuthor) { Person reviewer = PersonFaker.Generate(); article.Reviewer = reviewer; List <Blog> blogs = BlogFaker.Generate(1); blogs.Add(sharedBlog); reviewer.Blogs = blogs.ToHashSet(); blogs[0].Author = reviewer; Person author = PersonFaker.Generate(); blogs[1].Author = sharedBlogAuthor; Song authorSong = SongFaker.Generate(); author.FavoriteSong = authorSong; sharedBlogAuthor.FavoriteSong = authorSong; Song reviewerSong = SongFaker.Generate(); reviewer.FavoriteSong = reviewerSong; return(authorSong); }
private AuthorChainInstances GetAuthorChainInstances() { Article article = ArticleFaker.Generate(); Person author = PersonFaker.Generate(); article.Author = author; List <Blog> blogs = BlogFaker.Generate(2); author.Blogs = blogs.ToHashSet(); blogs[0].Reviewer = author; Person reviewer = PersonFaker.Generate(); blogs[1].Reviewer = reviewer; Food authorFood = FoodFaker.Generate(); author.FavoriteFood = authorFood; Food reviewerFood = FoodFaker.Generate(); reviewer.FavoriteFood = reviewerFood; return(new AuthorChainInstances(article, author, authorFood, reviewer, reviewerFood)); }
private (Article, Person, Food, Person, Food) GetAuthorChainInstances() { var article = ArticleFaker.Generate(); var author = PersonFaker.Generate(); article.Author = author; var blogs = BlogFaker.Generate(2); author.Blogs = blogs.ToHashSet(); blogs[0].Reviewer = author; var reviewer = PersonFaker.Generate(); blogs[1].Reviewer = reviewer; var authorFood = FoodFaker.Generate(); author.FavoriteFood = authorFood; var reviewerFood = FoodFaker.Generate(); reviewer.FavoriteFood = reviewerFood; return(article, author, authorFood, reviewer, reviewerFood); }
public SerializationTests(RedfishFixture fixture) { _fixture = fixture; _faker = new PersonFaker(); _protobufSerializer = new ProtobufSerializer(); _systemTextJsonSerializer = new SystemTextJsonSerializer(); _newtonsoftJsonSerializer = new NewtonsoftJsonSerializer(); }
public async Task Execute_InsertPerson() { var person = PersonFaker.Get(StatusEnumeration.Active).Generate().MapToAddRequest(); var result = await instance.Execute(person); result.Should().NotBe(Guid.Empty); }
public MainWindowModel() { People = new ObservableCollection <Person>(PersonFaker.Generate(1)); AddRandomPerson = new RelayCommand(o => People.Add(PersonFaker.Generate())); ReloadColumnsCommand = new RelayCommand(o => { var dynamicDataGrid = Application.Current.MainWindow.TryFindChild <DynamicDataGrid>(); dynamicDataGrid.ReloadColumns(); }); }
public async Task Execute_ReturnsPeople() { var people = PersonFaker.Get().Generate(3); personRepository.Setup(x => x.GetAll()) .ReturnsAsync(people); var result = await instance.Execute(); result.Should().BeEquivalentTo(people.MapToResponse()); }
public async Task Execute_ReturnsTrue_WhenSuccess() { var person = PersonFaker.Get().Generate().MapToUpdateRequest(); personRepository.Setup(x => x.Update(It.IsAny <Person>())) .ReturnsAsync(true); var result = await instance.Execute(person); result.Should().BeTrue(); }
public async Task Execute_ReturnsFalse_WhenPersonDoNotExist() { var person = PersonFaker.Get().Generate().MapToUpdateRequest(); personRepository.Setup(x => x.Update(It.IsAny <Person>())) .ReturnsAsync(false); var result = await instance.Execute(person); result.Should().BeFalse(); }
public async Task GetAll_ReturnsPeople() { var people = PersonFaker.Get().Generate(3); getPeopleUseCase.Setup(x => x.Execute()) .ReturnsAsync(people.MapToResponse()); var response = await instance.GetAll(); response.Result.Should().BeOfType <OkObjectResult>() .Which.Value.Should().BeEquivalentTo(people.MapToViewModel()); }
public async Task Update_ReturnsNotFound_WhenUpdateFailed() { var id = Guid.NewGuid(); var person = PersonFaker.Get().Generate().MapToViewModel(); updatePersonUseCase.Setup(x => x.Execute(It.IsAny <PersonUpdateRequest>())) .ReturnsAsync(false); var response = await instance.Update(id, person); response.Result.Should().BeOfType <NotFoundResult>(); }
public async Task Update_ReturnsId_WhenUpdatedSuccessfully() { var id = Guid.NewGuid(); var person = PersonFaker.Get().Generate().MapToViewModel(); updatePersonUseCase.Setup(x => x.Execute(It.IsAny <PersonUpdateRequest>())) .ReturnsAsync(true); var response = await instance.Update(id, person); response.Result.Should().BeOfType <OkObjectResult>() .Which.Value.Should().Be(id); }
public async Task Get_ReturnsPerson() { var id = Guid.NewGuid(); var person = PersonFaker.Get().Generate(); getPersonUseCase.Setup(x => x.Execute(id)) .ReturnsAsync(person.MapToResponse()); var response = await instance.Get(id); response.Result.Should().BeOfType <OkObjectResult>() .Which.Value.Should().BeEquivalentTo(person.MapToViewModel()); }
public BeforeDeleteWithDbValuesTests() { _person = PersonFaker.Generate(); var todo1 = TodoFaker.Generate(); var todo2 = TodoFaker.Generate(); var passport = PassportFaker.Generate(); _person.Passport = passport; _person.TodoItems = new HashSet <TodoItem> { todo1 }; _person.StakeHolderTodoItem = todo2; _options = InitInMemoryDb(context => { context.Set <Person>().Add(_person); context.SaveChanges(); }); }
public void BuildIncluded_DuplicateChildrenMultipleChains_OnceInOutput() { Person person = PersonFaker.Generate(); List <Article> articles = ArticleFaker.Generate(5); articles.ForEach(article => article.Author = person); articles.ForEach(article => article.Reviewer = person); IncludedResourceObjectBuilder builder = GetBuilder(); IReadOnlyCollection <RelationshipAttribute> authorChain = GetIncludedRelationshipsChain("author"); IReadOnlyCollection <RelationshipAttribute> reviewerChain = GetIncludedRelationshipsChain("reviewer"); foreach (Article article in articles) { builder.IncludeRelationshipChain(authorChain, article); builder.IncludeRelationshipChain(reviewerChain, article); } IList <ResourceObject> result = builder.Build(); Assert.Single(result); Assert.Equal(person.Name, result[0].Attributes["name"]); Assert.Equal(person.Id.ToString(), result[0].Id); }
public void BuildIncluded_DuplicateChildrenMultipleChains_OnceInOutput() { var person = PersonFaker.Generate(); var articles = ArticleFaker.Generate(5); articles.ForEach(a => a.Author = person); articles.ForEach(a => a.Reviewer = person); var builder = GetBuilder(); var authorChain = GetIncludedRelationshipsChain("author"); var reviewerChain = GetIncludedRelationshipsChain("reviewer"); foreach (var article in articles) { builder.IncludeRelationshipChain(authorChain, article); builder.IncludeRelationshipChain(reviewerChain, article); } var result = builder.Build(); Assert.Single(result); Assert.Equal(person.Name, result[0].Attributes["name"]); Assert.Equal(person.Id.ToString(), result[0].Id); }