public void ProductVersionProperlyMappedToProductVersionDto() { ProductVersionDto pDto1 = new ProductVersionDto { Id = 1, Product = "Great Product", Release = "V1", EndOfSupport = DateTime.Today }; ProductVersion p1 = new ProductVersion { Id = 1, Product = new Product { FullName = "Great Product" }, Release = "V1", EndOfSupport = DateTime.Today }; ProductVersionDto pDto2 = _mapper.Map <ProductVersionDto>(p1); Assert.NotNull(pDto2); Assert.True(pDto1.Equals(pDto2)); Assert.True(pDto1.Equals(pDto2, true)); }
public async void GetProductVersionByIdReturnsSingleProductVersion() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new ProductsController(context, _mapper)) { var result = await controller.GetProductVersion(1, 3); var okObjectResult = Assert.IsType <OkObjectResult>(result); var resultValue = okObjectResult.Value; ProductVersionDto p3 = GetTestProductVersionDto(3); Assert.NotNull(resultValue); Assert.IsType <ProductVersionDto>(resultValue); ProductVersionDto p = (ProductVersionDto)resultValue; Assert.True(p.Equals(p3)); Assert.True(p.Equals(p3, true)); } }
public async void GetProductVersionsReturnsListOfAuthors() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new ProductsController(context, _mapper)) { var result = await controller.GetProductVersions(1); ProductVersionDto p3 = GetTestProductVersionDto(3); Assert.NotNull(result); var okObjectResult = Assert.IsType <OkObjectResult>(result); Assert.IsAssignableFrom <IEnumerable <ProductVersionDto> >(okObjectResult.Value); IEnumerable <ProductVersionDto> resultValue = (IEnumerable <ProductVersionDto>)okObjectResult.Value; Assert.Equal(10, resultValue.Count()); ProductVersionDto p = (ProductVersionDto)resultValue.Where(r => r.Id == 3).FirstOrDefault(); Assert.True(p.Equals(p3)); Assert.True(p.Equals(p3, true)); } }
public void ProductVersionDtoEqualsReturnsCorrectValues() { ProductVersionDto p1 = new ProductVersionDto { Id = 1, Product = "Great Product", Release = "V1", EndOfSupport = DateTime.Today }; ProductVersionDto p2 = new ProductVersionDto { Id = 1, Product = "Great Product", Release = "V1", EndOfSupport = DateTime.Today }; ProductVersionDto p3 = new ProductVersionDto { Id = 3, Product = "Great Product", Release = "V1", EndOfSupport = DateTime.Today }; ProductVersionDto p4 = new ProductVersionDto { Id = 1, Product = "Great Product", Release = "V2", EndOfSupport = DateTime.Today }; Assert.True(p1.Equals(p2)); Assert.True(p1.Equals(p2, true)); Assert.False(p1.Equals(p3)); Assert.False(p1.Equals(p3, true)); Assert.True(p1.Equals(p4)); Assert.False(p1.Equals(p4, true)); }