public void ReturnCorrectInstance_OfType_BarRatingDto() { //Arrange var sut = new BarRatingDtoMapper(); var bar = new Bar { Id = 1, Name = "TestBar", Info = "TestInfo", }; var user = new User { Id = 1, UserName = "******", Email = "*****@*****.**", }; var barRating = new BarRating { BarId = 1, UserId = 1, Value = 5, CreatedOn = DateTime.MinValue, }; //Act var result = sut.MapDto(barRating); //Assert Assert.IsInstanceOfType(result, typeof(BarRatingDto)); Assert.AreEqual(result.BarId, barRating.BarId); Assert.AreEqual(result.UserId, barRating.UserId); Assert.AreEqual(result.Value, barRating.Value); }
public void MapFrom_Should_ReturnCorrectInstanceOf_BarRatingDto() { //Arrange var sut = new BarRatingDtoMapper(); var barRating = new BarRating { Bar = new Bar { Id = Guid.NewGuid(), Name = "testBar", Info = "testInfo", ImagePath = "testPath", Address = "testAddress", GoogleMapsURL = "GoogleMapsURL", Phone = "111-333-666" }, User = new User { Id = Guid.NewGuid(), UserName = "******", Email = "*****@*****.**" }, Value = 5, CreatedOn = DateTime.MinValue, }; //Act var result = sut.MapFrom(barRating); //Assert Assert.IsInstanceOfType(result, typeof(BarRatingDto)); }
public void ReturnCorrectInstance_OfType_ICollectionBarRatingDto() { //Arrange var sut = new BarRatingDtoMapper(); var bar1 = new Bar { Id = 1, Name = "TestBar1", Info = "TestInfo1", }; var bar2 = new Bar { Id = 2, Name = "TestBar2", Info = "TestInfo2", }; var user1 = new User { Id = 1, UserName = "******", Email = "*****@*****.**", }; var user2 = new User { Id = 2, UserName = "******", Email = "*****@*****.**", }; var barRatings = new List <BarRating> { new BarRating { BarId = 1, UserId = 1, Value = 2, CreatedOn = DateTime.MinValue, }, new BarRating { BarId = 2, UserId = 2, Value = 5, CreatedOn = DateTime.MinValue, } }; //Act var result = sut.MapDto(barRatings); //Assert Assert.IsInstanceOfType(result, typeof(ICollection <BarRatingDto>)); Assert.AreEqual(result.First().BarId, barRatings[0].BarId); Assert.AreEqual(result.First().UserId, barRatings[0].UserId); Assert.AreEqual(result.First().Value, barRatings[0].Value); Assert.AreEqual(result.Last().BarId, barRatings[1].BarId); Assert.AreEqual(result.Last().UserId, barRatings[1].UserId); Assert.AreEqual(result.Last().Value, barRatings[1].Value); }
public void MapFromCollection_Should_ReturnCorrectCountBarRatingBars() { //Arrange var sut = new BarRatingDtoMapper(); var barRating = new List <BarRating>() { new BarRating { Bar = new Bar { Id = Guid.NewGuid(), Name = "testBar", Info = "testInfo", ImagePath = "testPath", Address = "testAddress", GoogleMapsURL = "GoogleMapsURL", Phone = "111-333-666" }, User = new User { Id = Guid.NewGuid(), UserName = "******", Email = "*****@*****.**" }, Value = 5, CreatedOn = DateTime.MinValue, }, new BarRating { Bar = new Bar { Id = Guid.NewGuid(), Name = "testBar2", Info = "testInfo2", ImagePath = "testPath2", Address = "testAddress2", GoogleMapsURL = "GoogleMapsURL2", Phone = "111-333-6662" }, User = new User { Id = Guid.NewGuid(), UserName = "******", Email = "*****@*****.**" }, Value = 5, CreatedOn = DateTime.MinValue, }, }; //Act var result = sut.MapFrom(barRating); //Assert Assert.AreEqual(2, result.Count()); }
public void MapFrom_Should_CorrectlyMapFrom_BarRating_To_BarRatingDto() { //Arrange var sut = new BarRatingDtoMapper(); var barRating = new BarRating { Bar = new Bar { Id = Guid.NewGuid(), Name = "testBar", Info = "testInfo", ImagePath = "testPath", Address = "testAddress", GoogleMapsURL = "GoogleMapsURL", Phone = "111-333-666" }, User = new User { Id = Guid.NewGuid(), UserName = "******", Email = "*****@*****.**" }, Value = 5, CreatedOn = DateTime.MinValue, }; //Act var result = sut.MapFrom(barRating); //Assert Assert.AreEqual(result.BarId, barRating.BarId); Assert.AreEqual(result.UserId, barRating.UserId); Assert.AreEqual(result.Value, barRating.Value); Assert.AreEqual(result.CreatedOn, barRating.CreatedOn); }