public void When_SiteReference_Then_should_return_correct_result() { //Given //When var result = new AddedDocument() { Site = Site.Create(1,null,1,"Site Name", "Site Reference", "", new UserForAuditing()) }.SiteReference; //Then Assert.That(result, Is.EqualTo("Site Name")); }
public void Receives_List_Of_CreateDocumentRequests_And_Calls_Repo_To_Save_Accordingly() { // Given var userId = Guid.NewGuid(); var companyId = 1234; var createDocumentRequests = new List<CreateDocumentRequest>(); var passedRequest = new AddedDocument(); var createDocumentRequest = new CreateDocumentRequest() { Description = "description", DocumentLibraryId = 1234, DocumentType = DocumentTypeEnum.GRADocumentType, Filename = "helloworld.txt", SiteId = 123, Title = "title" }; _documentRepository.Setup(x => x.SaveOrUpdate(It.IsAny<AddedDocument>())).Callback<Document>(y => passedRequest = y as AddedDocument); createDocumentRequests.Add(createDocumentRequest); // When _target.Add(createDocumentRequests, userId, companyId); // Then _log.Verify(x => x.Add(It.IsAny<object>()), Times.Once()); _siteRepository.Verify(x => x.GetById(123), Times.Once()); _documentTypeRepository.Verify(x => x.GetById(1), Times.Once()); _userRepository.Verify(x => x.GetByIdAndCompanyId(It.IsAny<Guid>(), It.IsAny<long>())); _documentRepository.Verify(x => x.SaveOrUpdate(It.IsAny<AddedDocument>()), Times.Exactly(createDocumentRequests.Count())); Assert.That(passedRequest, Is.Not.Null); Assert.That(passedRequest.Description, Is.EqualTo(createDocumentRequest.Description)); Assert.That(passedRequest.DocumentLibraryId, Is.EqualTo(createDocumentRequest.DocumentLibraryId)); Assert.That(passedRequest.DocumentType, Is.Not.Null); Assert.That(passedRequest.Filename, Is.EqualTo(createDocumentRequest.Filename)); Assert.That(passedRequest.Site, Is.Not.Null); Assert.That(passedRequest.Title, Is.EqualTo(createDocumentRequest.Title)); Assert.That(passedRequest.ClientId, Is.EqualTo(companyId)); }