public void MapFrom_Should_CorrectlyMapRatingFrom_Bar_To_BarDto_WhenCollectionIsNotEmpty() { //Arrange var sut = new BarDtoMapper(); var bar = new Bar { Id = Guid.NewGuid(), Name = "testName", Info = "testInfo", ImagePath = "testPath", Address = "testAddress", GoogleMapsURL = "testMapsLink.gg", Phone = "111-333-666", Ratings = new List <BarRating>() { new BarRating { Value = 4.55, } } }; //Act var result = sut.MapFrom(bar); //Assert Assert.AreEqual(result.AverageRating, 4.55); }
public void MapFrom_Should_CorrectlyMapFrom_Bar_To_BarDto() { //Arrange var sut = new BarDtoMapper(); var bar = new Bar { Id = Guid.NewGuid(), Name = "testName", Info = "testInfo", ImagePath = "testPath", Address = "testAddress", GoogleMapsURL = "testMapsLink.gg", Phone = "111-333-666", }; //Act var result = sut.MapFrom(bar); //Assert Assert.AreEqual(result.Id, bar.Id); Assert.AreEqual(result.Name, bar.Name); Assert.AreEqual(result.Info, bar.Info); Assert.AreEqual(result.ImagePath, bar.ImagePath); Assert.AreEqual(result.Address, bar.Address); Assert.AreEqual(result.GoogleMapsURL, bar.GoogleMapsURL); Assert.AreEqual(result.Phone, bar.Phone); }
public void MapFrom_Should_ReturnCorrectInstanceOfCollection_BarDto() { //Arrange var sut = new BarDtoMapper(); var bars = new List <Bar>() { new Bar { Id = Guid.NewGuid(), Name = "testName", Info = "testInfo", ImagePath = "testPath", Address = "testAddress", GoogleMapsURL = "testMapsLink.gg", Phone = "111-333-666", }, new Bar { Id = Guid.NewGuid(), Name = "testName2", Info = "testInfo2", ImagePath = "testPath2", Address = "testAddress2", GoogleMapsURL = "testMapsLink2.gg", Phone = "111-333-6666", } }; //Act var result = sut.MapFrom(bars); //Assert Assert.IsInstanceOfType(result, typeof(List <BarDto>)); }
public void MapFromCollection_Should_ReturnCorrectCountBars() { //Arrange var sut = new BarDtoMapper(); var bars = new List <Bar>() { new Bar { Id = Guid.NewGuid(), Name = "testName", Info = "testInfo", ImagePath = "testPath", Address = "testAddress", GoogleMapsURL = "testMapsLink.gg", Phone = "111-333-666", }, new Bar { Id = Guid.NewGuid(), Name = "testName2", Info = "testInfo2", ImagePath = "testPath2", Address = "testAddress2", GoogleMapsURL = "testMapsLink2.gg", Phone = "111-333-6666", } }; //Act var result = sut.MapFrom(bars); //Assert Assert.AreEqual(2, result.Count()); }
public async Task CorrectlyAddCocktailsToBar() { //Arrange var options = TestUtilities.GetOptions(nameof(CorrectlyAddCocktailsToBar)); var mapper = new BarDtoMapper(); var mapperMock = new Mock <IDtoMapper <Bar, BarDto> >(); var searchMapperMock = new Mock <IDtoMapper <Bar, SearchBarDto> >(); var cocktailMapperMock = new Mock <IDtoMapper <Cocktail, CocktailDto> >(); var guid = Guid.NewGuid(); var entityDto = new BarDto { Id = guid, Name = "testBar", Info = "testInfo", Address = "testAddress", ImagePath = "testImagePath", Phone = "111-333-666" }; var bar = new Bar { Id = guid, Name = "testBar", Info = "testInfo", Address = "testAddress", ImagePath = "testImagePath", Phone = "111-333-666" }; var cocktail = new Cocktail { Id = Guid.NewGuid(), Name = "testCocktail", Info = "testCocktailInfo", }; var list = new List <string>() { "testCocktail" }; using (var actContext = new CWContext(options)) { //Act await actContext.Bars.AddAsync(bar); await actContext.Cocktails.AddAsync(cocktail); await actContext.SaveChangesAsync(); } using (var assertContext = new CWContext(options)) { //Act & Assert var sut = new BarService(assertContext, mapperMock.Object, searchMapperMock.Object, cocktailMapperMock.Object); var result = await sut.AddCocktailsAsync(entityDto, list); Assert.AreEqual(1, await assertContext.BarCocktails.CountAsync()); } }