public void TestGetAll() { // Arrange ExhibitsService service = Scope.Resolve <ExhibitsService>(); // Act IEnumerable <Exhibit> result = service.Get(); // Assert Assert.IsTrue(_exhibits.Except(result).Count() == 0); }
public void TestGetById() { // Arrange ExhibitsService service = Scope.Resolve <ExhibitsService>(); // Act Exhibit result = service.Get(_exhibits.First().ExhibitID); // Assert Assert.IsNotNull(result); }
public void GetByArticle() { // Prepare test data Exhibit firstExhibit = _exhibits.First(); Article art = DbFactory.Create <Article>((item) => item.Exhibits = new[] { firstExhibit }); // Arrange ExhibitsService service = Scope.Resolve <ExhibitsService>(); // Act IEnumerable <Exhibit> result = service.GetByArticle(art.ArticleID); // Assert Assert.IsNotNull(result.Any()); }
public void GetByEvent() { // Prepare test data Exhibit firstExhibit = _exhibits.First(); Event evnt = DbFactory.CreateEvent((item) => item.Exhibits = new[] { firstExhibit }); // Arrange ExhibitsService service = Scope.Resolve <ExhibitsService>(); // Act IEnumerable <Exhibit> result = service.GetByEvent(evnt.EventID); // Assert Assert.IsNotNull(result); }
public StandsControllerTests() { var mockRepo = new Mock <IStandsRepository>(); var mockRepoEmpty = new Mock <IStandsRepository>(); List <Hall> _hallsEmpty = new List <Hall>() { new Hall() { Id = HallId, TitleBe = "Be", TitleEn = "En", TitleRu = "Ru", Photo = new PhotoInfo(), Stands = new List <Stand>() } }; _halls = new List <Hall>() { new Hall() { Id = "123456789012345678901234", TitleBe = "Be", TitleEn = "En", TitleRu = "Ru", Photo = new PhotoInfo(), Stands = new List <Stand>() { new Stand() { Id = "123456789012345678901111", TitleRu = "TitleRu", TitleEn = "TitleEn", TitleBe = "TitleBe", DescriptionBe = "Be1", DescriptionEn = "En", DescriptionRu = "Ru1", Photo = new PhotoInfo(), Exhibits = new List <Exhibit>() { new Exhibit() { Id = "123456789012345678901212", TitleRu = "TitleRu", TitleEn = "TitleEn", TitleBe = "TitleBe", TextBe = "Be1", TextEn = "En1", TextRu = "Ru1", Photos = new List <PhotoInfo>(), }, new Exhibit() { Id = "123456789012345678901213", TitleRu = "TitleRu2", TitleEn = "TitleEn2", TitleBe = "TitleBe2", TextBe = "Be12", TextEn = "En2", TextRu = "Ru12", Photos = new List <PhotoInfo>(), } } }, new Stand() { Id = "123456789012345678901112", TitleRu = "TitleRu", TitleEn = "TitleEn", TitleBe = "TitleBe", DescriptionBe = "Be1", DescriptionEn = "En", DescriptionRu = "Ru1", Photo = new PhotoInfo(), Exhibits = new List <Exhibit>() { new Exhibit() { Id = "123456789012345678901313", TitleRu = "TitleRu3", TitleBe = "TitleBe3", TextBe = "Be13", TextEn = "En13", TextRu = "Ru13", Photos = new List <PhotoInfo>(), } } }, new Stand() { Id = "123456789012345678903111", TitleRu = "TitleRu", TitleEn = "TitleEn", TitleBe = "TitleBe", DescriptionBe = "Be1", DescriptionEn = "En", DescriptionRu = "Ru1", Photo = new PhotoInfo(), Exhibits = new List <Exhibit>() { new Exhibit() { Id = "123456789012345678901415", TitleRu = "TitleRu24", TitleEn = "TitleEn24", TitleBe = "TitleBe24", TextBe = "Be124", TextRu = "Ru124", Photos = new List <PhotoInfo>(), } } }, } } }; mockRepo.Setup(repo => repo.GetAllAsync(It.IsAny <string>())).ReturnsAsync((string hallId) => _halls.FirstOrDefault(h => h.Id.Equals(hallId))?.Stands.ToList()); mockRepoEmpty.Setup(repo => repo.GetAllAsync(It.IsAny <string>())).ReturnsAsync((string hallId) => _hallsEmpty.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.ToList()); mockRepo.Setup(repo => repo.GetAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync((string hallId, string id) => _halls.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.Where(s => s.Id.Equals(id)).FirstOrDefault()); mockRepo.Setup(repo => repo.CreateAsync(It.IsAny <string>(), It.IsAny <Stand>())) .Callback((string hallId, Stand stand) => { _halls.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.Add(stand); }) .ReturnsAsync(() => "123456782032345347406865"); mockRepo.Setup(repo => repo.UpdateAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Stand>())) .Callback((string hallId, string id, Stand standIn) => { var stand = _halls.FirstOrDefault(h => h.Id.Equals(hallId)).Stands .FirstOrDefault(s => s.Id.Equals(id)); stand.DescriptionBe = standIn.DescriptionBe; stand.DescriptionEn = standIn.DescriptionEn; stand.DescriptionRu = standIn.DescriptionRu; stand.TitleBe = standIn.TitleBe; stand.TitleEn = standIn.TitleEn; stand.TitleRu = standIn.TitleRu; }); mockRepo.Setup(repo => repo.RemoveAsync(It.IsAny <string>(), It.IsAny <string>())) .Callback((string hallId, string id) => { var stand = _halls.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.FirstOrDefault(e => e.Id.Equals(id)); _halls.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.Remove(stand); }); var mockRepoExhibit = new Mock <IExhibitsRepository>(); var mockRepoEmptyExhibits = new Mock <IExhibitsRepository>(); mockRepo.SetupAllProperties(); mockRepoEmpty.SetupAllProperties(); mockRepoExhibit.Setup(repo => repo.GetAllAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync((string hallId, string standId) => _halls.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.FirstOrDefault(s => s.Id.Equals(standId)).Exhibits.ToList()); mockRepoEmptyExhibits.Setup(repo => repo.GetAllAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync((string hallId, string standId) => _hallsEmpty.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.FirstOrDefault(s => s.Id.Equals(standId)).Exhibits.ToList()); mockRepoExhibit.Setup(repo => repo.GetAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync((string hallId, string standId, string id) => _halls.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.FirstOrDefault(s => s.Id.Equals(standId)).Exhibits?.Where(e => e.Id.Equals(id)).FirstOrDefault()); _exhibitsService = new ExhibitsService(mockRepoExhibit.Object); _service = new StandsService(mockRepo.Object, _exhibitsService); _standsController = new StandsController(mockRepo.Object, _service, new CompareService()); _exhibitsServiceEmptyRepo = new ExhibitsService(mockRepoEmptyExhibits.Object); _serviceEmptyRepo = new StandsService(mockRepoEmpty.Object, _exhibitsServiceEmptyRepo); _standsController2 = new StandsController(mockRepoEmpty.Object, _serviceEmptyRepo, new CompareService()); }
public HomeController(EventsService events, ExhibitsService exhibits) { _events = events; _exhibits = exhibits; }
public HallsServiceTests() { var mockRepo = new Mock <IHallsRepository>(); var mockRepoEmpty = new Mock <IHallsRepository>(); List <Hall> _hallsEmpty = new List <Hall>(); _halls = new List <Hall>() { new Hall() { Id = "123456789012345678901234", TitleBe = "Be", TitleEn = "En", TitleRu = "Ru", Photo = new PhotoInfo(), Stands = new List <Stand>() { new Stand() { Id = "123456789012345678901111", TitleRu = "TitleRu", TitleEn = "TitleEn", TitleBe = "TitleBe", DescriptionBe = "Be1", DescriptionEn = "En", DescriptionRu = "Ru1", Photo = new PhotoInfo(), Exhibits = new List <Exhibit>() { new Exhibit() { Id = "123456789012345678901212", TitleRu = "TitleRu", TitleEn = "TitleEn", TitleBe = "TitleBe", TextBe = "Be1", TextEn = "En1", TextRu = "Ru1", Photos = new List <PhotoInfo>() }, new Exhibit() { Id = "123456789012345678901213", TitleRu = "TitleRu2", TitleEn = "TitleEn2", TitleBe = "TitleBe2", TextBe = "Be12", TextEn = "En2", TextRu = "Ru12", Photos = new List <PhotoInfo>() } } }, new Stand() { Id = "123456789012345678901112", TitleRu = "TitleRu", TitleEn = "TitleEn", TitleBe = "TitleBe", DescriptionBe = "Be1", DescriptionEn = "En", DescriptionRu = "Ru1", Photo = new PhotoInfo(), Exhibits = new List <Exhibit>() { new Exhibit() { Id = "123456789012345678901313", TitleRu = "TitleRu3", TitleBe = "TitleBe3", TextBe = "Be13", TextEn = "En13", TextRu = "Ru13", Photos = new List <PhotoInfo>() } } }, new Stand() { Id = "123456789012345678903111", TitleRu = "TitleRu", TitleEn = "TitleEn", TitleBe = "TitleBe", DescriptionBe = "Be1", DescriptionEn = "En", DescriptionRu = "Ru1", Photo = new PhotoInfo(), Exhibits = new List <Exhibit>() { new Exhibit() { Id = "123456789012345678901415", TitleRu = "TitleRu24", TitleEn = "TitleEn24", TitleBe = "TitleBe24", TextBe = "Be124", TextRu = "Ru124", Photos = new List <PhotoInfo>() } } }, } }, new Hall() { Id = "123456789012345678901235", TitleBe = "Be", TitleEn = "En", TitleRu = "Ru", Photo = new PhotoInfo(), Stands = new List <Stand>() } }; mockRepo.Setup(repo => repo.GetAllAsync()).ReturnsAsync(() => _halls.ToList()); mockRepoEmpty.Setup(repo => repo.GetAllAsync()).ReturnsAsync(() => _hallsEmpty.ToList()); mockRepo.Setup(repo => repo.GetAsync(It.IsAny <string>())).ReturnsAsync((string id) => _halls.FirstOrDefault(h => h.Id.Equals(id))); var mockRepoExhibit = new Mock <IExhibitsRepository>(); var mockRepoEmptyExhibits = new Mock <IExhibitsRepository>(); mockRepoExhibit.Setup(repo => repo.GetAllAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync((string hallId, string standId) => _halls.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.FirstOrDefault(s => s.Id.Equals(standId)).Exhibits.ToList()); mockRepoEmptyExhibits.Setup(repo => repo.GetAllAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync((string hallId, string standId) => _hallsEmpty.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.FirstOrDefault(s => s.Id.Equals(standId)).Exhibits.ToList()); mockRepoExhibit.Setup(repo => repo.GetAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync((string hallId, string standId, string id) => _halls.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.FirstOrDefault(s => s.Id.Equals(standId)).Exhibits?.Where(e => e.Id.Equals(id)).FirstOrDefault()); var mockRepoStands = new Mock <IStandsRepository>(); var mockRepoEmptyStands = new Mock <IStandsRepository>(); mockRepoStands.Setup(repo => repo.GetAllAsync(It.IsAny <string>())).ReturnsAsync((string hallId) => _halls.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.ToList()); mockRepoEmptyStands.Setup(repo => repo.GetAllAsync(It.IsAny <string>())).ReturnsAsync((string hallId) => _hallsEmpty.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.ToList()); mockRepoStands.Setup(repo => repo.GetAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync((string hallId, string id) => _halls.FirstOrDefault(h => h.Id.Equals(hallId)).Stands.Where(s => s.Id.Equals(id)).FirstOrDefault()); mockRepo.SetupAllProperties(); mockRepoEmpty.SetupAllProperties(); _exhibitsService = new ExhibitsService(mockRepoExhibit.Object); _standsService = new StandsService(mockRepoStands.Object, _exhibitsService); _service = new HallsService(mockRepo.Object, _standsService); _exhibitsServiceEmptyRepo = new ExhibitsService(mockRepoEmptyExhibits.Object); _standsServiceEmptyRepo = new StandsService(mockRepoEmptyStands.Object, _exhibitsServiceEmptyRepo); _serviceEmptyRepo = new HallsService(mockRepoEmpty.Object, _standsServiceEmptyRepo); }
public ExhibitsController(ExhibitsService exhibits) { _exhibits = exhibits; }