public void AuthorProperlyMappedToAuthorDto() { AuthorDto aDto1 = new AuthorDto { Id = 1, Alias = "ALIAS", AitName = "Tech", FirstName = "Tech", LastName = "Writer", Email = "*****@*****.**", IsFormerAuthor = false }; Author a1 = new Author { Id = 1, Alias = "ALIAS", AitName = "Tech", FirstName = "Tech", LastName = "Writer", Email = "*****@*****.**", IsFormerAuthor = false }; AuthorDto aDto2 = _mapper.Map <AuthorDto>(a1); Assert.NotNull(aDto2); Assert.True(aDto1.Equals(aDto2)); Assert.True(aDto1.Equals(aDto2, true)); }
public async void GetAuthorByIdReturnsSingleAuthor() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new AuthorsController(context, _mapper)) { var result = await controller.GetAuthor(3); var okObjectResult = Assert.IsType <OkObjectResult>(result); var resultValue = okObjectResult.Value; AuthorDto a3 = GetTestAuthorDto(3); Assert.NotNull(resultValue); Assert.IsType <AuthorDto>(resultValue); AuthorDto a = (AuthorDto)resultValue; Assert.True(a.Equals(a3)); Assert.True(a.Equals(a3, true)); } }
public void GetAuthorsReturnsListOfAuthors() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new AuthorsController(context, _mapper)) { var result = controller.GetAuthors(); AuthorDto a3 = GetTestAuthorDto(3); Assert.NotNull(result); var okObjectResult = Assert.IsType <OkObjectResult>(result); var resultValue = okObjectResult.Value; Assert.IsAssignableFrom <IEnumerable <AuthorDto> >(resultValue); Assert.NotEmpty((IEnumerable <AuthorDto>)resultValue); IEnumerable <AuthorDto> resultValueList = (IEnumerable <AuthorDto>)resultValue; Assert.Equal(10, resultValueList.Count()); AuthorDto a = (AuthorDto)resultValueList.Where(r => r.Id == 3).FirstOrDefault(); Assert.True(a.Equals(a3)); Assert.True(a.Equals(a3, true)); } }
public void AuthorEqualsReturnsCorrectValues() { AuthorDto a1 = new AuthorDto { Id = 1, Alias = "ALIAS", AitName = "Tech", FirstName = "Tech", LastName = "Writer", Email = "*****@*****.**", IsFormerAuthor = false }; AuthorDto a2 = new AuthorDto { Id = 1, Alias = "ALIAS", AitName = "Tech", FirstName = "Tech", LastName = "Writer", Email = "*****@*****.**", IsFormerAuthor = false }; AuthorDto a3 = new AuthorDto { Id = 3, Alias = "ALIAS", AitName = "Tech", FirstName = "Tech", LastName = "Writer", Email = "*****@*****.**", IsFormerAuthor = false }; AuthorDto a4 = new AuthorDto { Id = 1, Alias = "SAILA", AitName = "Tech", FirstName = "Tech", LastName = "Writer", Email = "*****@*****.**", IsFormerAuthor = false }; Assert.True(a1.Equals(a2)); Assert.True(a1.Equals(a2, true)); Assert.False(a1.Equals(a3)); Assert.False(a1.Equals(a3, true)); Assert.True(a1.Equals(a4)); Assert.False(a1.Equals(a4, true)); }