public async void GetDocumentByIdReturnsSingleDocument()
        {
            using (var context = DbTestContext.GenerateContextWithData())
                using (var controller = new DocumentsController(context, _mapper))
                {
                    var result = await controller.GetDocument(3);

                    var okObjectResult = Assert.IsType <OkObjectResult>(result);
                    var resultValue    = okObjectResult.Value;

                    DocumentDto a3 = GetTestDocumentDtoFromContext(3);

                    Assert.NotNull(resultValue);
                    Assert.IsType <DocumentDto>(resultValue);
                    DocumentDto a = (DocumentDto)resultValue;
                    Assert.True(a.Equals(a3));
                    Assert.True(a.Equals(a3, true));
                }
        }
        public void GetDocumentsReturnsListOfDocuments()
        {
            using (var context = DbTestContext.GenerateContextWithData())
                using (var controller = new DocumentsController(context, _mapper))
                {
                    var         result = controller.GetDocuments();
                    DocumentDto d3     = GetTestDocumentDtoFromContext(3);

                    Assert.NotNull(result);
                    var okObjectResult = Assert.IsType <OkObjectResult>(result);
                    var resultValue    = okObjectResult.Value;
                    Assert.IsAssignableFrom <IEnumerable <DocumentDto> >(resultValue);
                    Assert.NotEmpty((IEnumerable <DocumentDto>)resultValue);

                    IEnumerable <DocumentDto> resultValueList = (IEnumerable <DocumentDto>)resultValue;

                    DocumentDto d = (DocumentDto)resultValueList.Single(r => r.Id == 3);
                    Assert.True(d.Equals(d3));
                    Assert.True(d.Equals(d3, true));
                }
        }
コード例 #3
0
        public void DocumentProperlyMappedToDocumentDto()
        {
            DocumentDto documentDto = new DocumentDto
            {
                Id               = 1,
                AitId            = 987456,
                Title            = "Document 1",
                ShortDescription = "This is a test document.",

                ProductVersionId  = 1,
                DocumentAuthorIds = new List <int> {
                    1, 2
                },
                DocumentCatalogIds = new List <int> {
                    1, 2
                },
                DocumentTypeId = 1,

                HtmlLink  = "document1/html/index.htm",
                PdfLink   = "document1/pdf/document1.pdf",
                WordLink  = "document1/word/document1.doc",
                OtherLink = null,

                IsFitForClients     = true,
                IsPublished         = true,
                LatestTopicsUpdated = "This is the first version of the document."
            };

            Document document = new Document
            {
                Id               = 1,
                AitId            = 987456,
                Title            = "Document 1",
                ShortDescription = "This is a test document.",

                ProductVersionId = 1,
                DocumentAuthors  = new List <DocumentAuthor>
                {
                    new DocumentAuthor {
                        AuthorId = 1
                    },
                    new DocumentAuthor {
                        AuthorId = 2
                    }
                },
                DocumentCatalogs = new List <DocumentCatalog>
                {
                    new DocumentCatalog {
                        CatalogId = 1
                    },
                    new DocumentCatalog {
                        CatalogId = 2
                    }
                },
                DocumentTypeId = 1,

                HtmlLink  = "document1/html/index.htm",
                PdfLink   = "document1/pdf/document1.pdf",
                WordLink  = "document1/word/document1.doc",
                OtherLink = null,

                IsFitForClients = true,
                Updates         = new List <DocumentUpdate>
                {
                    new DocumentUpdate
                    {
                        IsPublished         = true,
                        LatestTopicsUpdated = "This is the first version of the document."
                    }
                }
            };

            DocumentDto documentDto2 = _mapper.Map <DocumentDto>(document);

            Assert.NotNull(documentDto2);
            Assert.True(documentDto.Equals(documentDto2));
            Assert.True(documentDto.Equals(documentDto2, true));
        }
コード例 #4
0
        public void DocumentDtoEqualsReturnsCorrectValues()
        {
            DocumentDto d1 = new DocumentDto
            {
                Id               = 1,
                AitId            = 987456,
                Title            = "Document 1",
                ShortDescription = "This is a test document.",

                ProductVersionId  = 1,
                DocumentAuthorIds = new List <int> {
                    1, 2
                },
                DocumentCatalogIds = new List <int> {
                    1, 2
                },
                DocumentTypeId = 1,

                HtmlLink  = "document1/html/index.htm",
                PdfLink   = "document1/pdf/document1.pdf",
                WordLink  = "document1/word/document1.doc",
                OtherLink = null,

                IsFitForClients     = true,
                IsPublished         = true,
                LatestTopicsUpdated = "This is the first version of the document."
            };

            DocumentDto d2 = new DocumentDto
            {
                Id               = 1,
                AitId            = 987456,
                Title            = "Document 1",
                ShortDescription = "This is a test document.",

                ProductVersionId  = 1,
                DocumentAuthorIds = new List <int> {
                    1, 2
                },
                DocumentCatalogIds = new List <int> {
                    1, 2
                },
                DocumentTypeId = 1,

                HtmlLink  = "document1/html/index.htm",
                PdfLink   = "document1/pdf/document1.pdf",
                WordLink  = "document1/word/document1.doc",
                OtherLink = null,

                IsFitForClients     = true,
                IsPublished         = true,
                LatestTopicsUpdated = "This is the first version of the document."
            };

            DocumentDto d3 = new DocumentDto
            {
                Id               = 2,
                AitId            = 987457,
                Title            = "Document 2",
                ShortDescription = "This is a second test document.",

                ProductVersionId  = 2,
                DocumentAuthorIds = new List <int> {
                    2
                },
                DocumentCatalogIds = new List <int> {
                    1
                },
                DocumentTypeId = 2,

                HtmlLink  = "document2/html/index.htm",
                PdfLink   = "document2/pdf/document2.pdf",
                WordLink  = "document2/word/document2.doc",
                OtherLink = null,

                IsFitForClients     = false,
                IsPublished         = false,
                LatestTopicsUpdated = "This is the first version of the document."
            };
            DocumentDto d4 = new DocumentDto
            {
                Id = 1
            };

            Assert.True(d1.Equals(d2));
            Assert.True(d1.Equals(d2, true));
            Assert.False(d1.Equals(d3));
            Assert.False(d1.Equals(d3, true));
            Assert.True(d1.Equals(d4));
            Assert.False(d1.Equals(d4, true));
        }