コード例 #1
0
        public void TrimData()
        {
            if (FullDocumentName == null)
            {
                FullDocumentName = "";
            }

            if (DocumentName == null)
            {
                DocumentName = "";
            }

            if (DocumentExtension == null)
            {
                DocumentExtension = "";
            }

            if (Remarks == null)
            {
                Remarks = "";
            }

            FullDocumentName  = FullDocumentName.Trim();
            DocumentName      = DocumentName.Trim();
            DocumentExtension = DocumentExtension.Trim();
            Remarks           = Remarks.Trim();
        }
コード例 #2
0
        public void ToString_returns_value()
        {
            var name  = new DocumentName("value");
            var value = name.ToString();

            value.Should().Be("value");
        }
コード例 #3
0
        public void ParsesName(string identifier, string language, string fileName)
        {
            var uut = new DocumentName(identifier);

            Assert.AreEqual(language, uut.Language);
            Assert.AreEqual(fileName, uut.FileName);
        }
コード例 #4
0
        string GenerateExcelWorksheet()
        {
            var r = new StringBuilder();

            r.AddFormattedLine(@"<Worksheet ss:Name=""{0}"">",
                               DocumentName.Remove("/", @"\", "?", "*", ":", "[", "]", "\r", "\n").KeepReplacing("  ", " ").Summarize(31, enforceMaxLength: true).XmlEncode());
            r.AddFormattedLine(@"<Table DefaultColumnWidth=""{0}"">", DefaultColumnWidth);

            r.AppendLine(Columns.Select((h, i) => GenerateColumnTag(h, i + 1)).Trim().ToLinesString());

            r.AppendLine(GenerateHeaderGroupings());

            if (!ExcludeHeader)
            {
                r.AppendLine(GenerateSheetHeaderRow());
            }

            r.AppendLine(GenerateDataRows());

            r.AppendLine(@"</Table>");

            r.AppendLine(GenerateDropDownDataValidation());

            r.AppendLine(GenerateWorksheetSettings());

            r.AppendLine(@"</Worksheet>");

            return(r.ToString());
        }
コード例 #5
0
        public void TryCreate_returns_true_if_value_is_valid_id(string value)
        {
            var success = DocumentName.TryCreate(value, out var name);

            success.Should().BeTrue();
            name.Should().NotBeNull();
        }
コード例 #6
0
        public void DocsId_instances_can_implicitly_be_converted_to_string()
        {
            var    name  = new DocumentName("value");
            string value = name;

            value.Should().Be("value");
        }
コード例 #7
0
ファイル: FTService.cs プロジェクト: AndriiZ/BH
        public bool IndexText(string documentName,
                              string documentVersion,
                              string contentText,
                              string robotName)
        {
            return(TryCatch <bool>(() =>
            {
                if (!IsStarted())
                {
                    throw new Exception("Service is not started.");
                }

                var docName = new DocumentName(documentName, documentVersion, robotName);

                return ActiveInstance.IndexContent(docName.ToString(), contentText, FTSearch.ContentType.Text);

                //{
                //    foreach (var file in IndexedFilesInMemory)
                //    {
                //        File.AppendAllText(string.Format(@"{0}\log.txt", Path),
                //                           string.Format(@"[{0}] {1}", DateTime.Now.ToString(), file));
                //    }
                //}
            }));
        }
コード例 #8
0
ファイル: Index.cshtml.cs プロジェクト: zhouxuzone/abp
 private async Task <DocumentWithDetailsDto> GetSpecificDocumentOrDefaultAsync(string languageCode)
 {
     if (DocumentName.IsNullOrWhiteSpace())
     {
         return(await _documentAppService.GetDefaultAsync(
                    new GetDefaultDocumentInput
         {
             ProjectId = Project.Id,
             LanguageCode = languageCode,
             Version = Version
         }
                    ));
     }
     else
     {
         return(await _documentAppService.GetAsync(
                    new GetDocumentInput
         {
             ProjectId = Project.Id,
             Name = DocumentNameWithExtension,
             LanguageCode = languageCode,
             Version = Version
         }
                    ));
     }
 }
コード例 #9
0
ファイル: NamesTest.cs プロジェクト: kave-cc/csharp-commons
        public void DoesNotBreakForRegularStringsThatDoNotNeedToBeReplaced_Document()
        {
            var actual   = Names.Document("CSharp {..}");
            var expected = new DocumentName("CSharp {..}");

            Assert.AreEqual(expected, actual);
        }
コード例 #10
0
        public async Task <IActionResult> Edit(int id, [Bind("DocumentNameId,DocumentName1")] DocumentName documentName)
        {
            if (id != documentName.DocumentNameId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(documentName);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DocumentNameExists(documentName.DocumentNameId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(documentName));
        }
コード例 #11
0
        public void TryCreate_returns_false_for_invalid_values(string value)
        {
            var success = DocumentName.TryCreate(value, out var name);

            success.Should().BeFalse();
            name.Should().BeNull();
        }
コード例 #12
0
        public void DefaultValues()
        {
            var sut = new DocumentName();

            Assert.AreEqual("???", sut.Language);
            Assert.AreEqual("???", sut.FileName);
            Assert.IsTrue(sut.IsUnknown);
        }
コード例 #13
0
        public void ShouldBeEqual()
        {
            var timestamp     = new Timestamp(123456789);
            var guid          = new Guid("a9d7a3ae-df80-4925-a542-17347df3a280");
            var fileName      = new FileName("file.pdf");
            var documentName1 = new DocumentName(timestamp, guid, fileName);
            var documentName2 = new DocumentName(timestamp, guid, fileName);

            Assert.Equal(documentName1, documentName2);
        }
コード例 #14
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (DocumentId != null ? DocumentId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DocumentName != null ? DocumentName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Relationship != null ? Relationship.GetHashCode() : 0);
         return(hashCode);
     }
 }
コード例 #15
0
        private async Task SetDocumentAsync()
        {
            DocumentNameWithExtension = DocumentName + "." + Project.Format;

            try
            {
                if (DocumentName.IsNullOrWhiteSpace())
                {
                    Document = await _documentAppService.GetDefaultAsync(
                        new GetDefaultDocumentInput
                    {
                        ProjectId    = Project.Id,
                        LanguageCode = LanguageCode,
                        Version      = Version
                    }
                        );
                }
                else
                {
                    Document = await _documentAppService.GetAsync(
                        new GetDocumentInput
                    {
                        ProjectId    = Project.Id,
                        Name         = DocumentNameWithExtension,
                        LanguageCode = LanguageCode,
                        Version      = Version
                    }
                        );
                }
            }
            catch (DocumentNotFoundException)
            {
                if (LanguageCode != DefaultLanguageCode)
                {
                    Document = await _documentAppService.GetAsync(
                        new GetDocumentInput
                    {
                        ProjectId    = Project.Id,
                        Name         = DocumentNameWithExtension,
                        LanguageCode = DefaultLanguageCode,
                        Version      = Version
                    }
                        );

                    DocumentLanguageIsDifferent = true;
                }
                else
                {
                    throw;
                }
            }

            await ConvertDocumentContentToHtmlAsync();
        }
コード例 #16
0
        public async Task <IActionResult> Create([Bind("DocumentNameId,DocumentName1")] DocumentName documentName)
        {
            if (ModelState.IsValid)
            {
                _context.Add(documentName);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(documentName));
        }
コード例 #17
0
        public void ShouldConvertToString()
        {
            var timestamp    = new Timestamp(123456789);
            var guid         = new Guid("a9d7a3ae-df80-4925-a542-17347df3a280");
            var fileName     = new FileName("file.pdf");
            var documentName = new DocumentName(timestamp, guid, fileName);

            Assert.Equal(
                "0123456789_a9d7a3aedf804925a54217347df3a280_file.pdf",
                documentName.ToString());
        }
コード例 #18
0
        public bool Equals(INetworkCommand networkCommand)
        {
            if (!(networkCommand is CreateEntryRequestNetworkCommand <T>))
            {
                return(false);
            }

            CreateEntryRequestNetworkCommand <T> other = (CreateEntryRequestNetworkCommand <T>)networkCommand;

            return(ParentPath.Equals(other.ParentPath) && DocumentName.Equals(other.DocumentName));
        }
コード例 #19
0
        private void SetPageParams(ProjectDto project)
        {
            ProjectFormat = project.Format;

            if (DocumentName.IsNullOrWhiteSpace())
            {
                DocumentName = project.DefaultDocumentName;
            }

            DocumentNameWithExtension = DocumentName + "." + project.Format;
        }
コード例 #20
0
        public void Parse_can_parse_same_version_references(string reference, string name)
        {
            // ARRANGE
            var expectedName = new DocumentName(name);

            // ACT
            var parsed = DocumentReference.Parse(reference);

            // ASSERT
            parsed
            .Should().NotBeNull()
            .And.BeOfType <SameVersionDocumentReference>()
            .Which.Name.Should().Be(expectedName);
        }
コード例 #21
0
        public String getName()
        {
            String FileName = String.Empty;

            if (!String.IsNullOrEmpty(DocumentName))
            {
                int TiledAt = DocumentName.IndexOf('~');
                if (TiledAt > 0)
                {
                    FileName = DocumentName.Substring(TiledAt + 1);
                }
            }
            return(FileName);
        }
コード例 #22
0
        public void TryParse_returns_true_for_same_version_references(string reference, string name)
        {
            // ARRANGE
            var expectedName = new DocumentName(name);

            // ACT
            var success = DocumentReference.TryParse(reference, out var parsed);

            // ASSERT
            success
            .Should().BeTrue();

            parsed
            .Should().NotBeNull()
            .And.BeOfType <SameVersionDocumentReference>()
            .Which.Name.Should().Be(expectedName);
        }
コード例 #23
0
        public void TryCreate_returns_false_if_value_contains_invalid_characters(string reserved)
        {
            var success = DocumentName.TryCreate($"prefix{reserved}suffix", out var name);

            success.Should().BeFalse();
            name.Should().BeNull();

            success = DocumentName.TryCreate($"prefix{reserved}", out name);
            success.Should().BeFalse();
            name.Should().BeNull();

            success = DocumentName.TryCreate($"{reserved}suffix", out name);
            success.Should().BeFalse();
            name.Should().BeNull();

            success = DocumentName.TryCreate(reserved, out name);
            success.Should().BeFalse();
            name.Should().BeNull();
        }
コード例 #24
0
        private string GetDocumentHref(bool isBaseUrlIncluded)
        {
            string libraryUrl  = LibraryName.ToLower() + "/" + ChildDocumentLibrary.ToLower();
            string documentUrl = DocumentName.ToLower() + DocumentType.ToLower();
            string url;

            if (this.Culture == null)
            {
                url = this.BaseUrl;
            }
            else
            {
                url = ActiveBrowser.Url.Substring(0, 20);
            }

            string href = BATFeather.Wrappers().Frontend().MediaWidgets().MediaWidgetsWrapper().GetMediaSource(isBaseUrlIncluded, libraryUrl, documentUrl, url, "docs", currentProviderUrlName);

            return(href);
        }
コード例 #25
0
        private string GetDocumentHref(bool isBaseUrlIncluded)
        {
            currentProviderUrlName = BAT.Arrange(this.TestName).ExecuteArrangement("GetCurrentProviderUrlName").Result.Values["CurrentProviderUrlName"];
            string libraryUrl  = LibraryName.ToLower();
            string documentUrl = DocumentName.ToLower() + DocumentType.ToLower();
            string url;

            if (this.Culture == null)
            {
                url = this.BaseUrl;
            }
            else
            {
                url = ActiveBrowser.Url.Substring(0, 20);
            }

            string href = BATFeather.Wrappers().Frontend().MediaWidgets().MediaWidgetsWrapper().GetMediaSource(isBaseUrlIncluded, libraryUrl, documentUrl, url, "docs", currentProviderUrlName);

            return(href);
        }
コード例 #26
0
        public async stt::Task GetDocumentRequestObjectAsync()
        {
            moq::Mock <Documents.DocumentsClient> mockGrpcClient = new moq::Mock <Documents.DocumentsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetDocumentRequest request = new GetDocumentRequest
            {
                DocumentName = DocumentName.FromProjectKnowledgeBaseDocument("[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"),
            };
            Document expectedResponse = new Document
            {
                DocumentName   = DocumentName.FromProjectKnowledgeBaseDocument("[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"),
                DisplayName    = "display_name137f65c2",
                MimeType       = "mime_type606a0ffc",
                KnowledgeTypes =
                {
                    Document.Types.KnowledgeType.Unspecified,
                },
                ContentUri = "content_uriaf560198",
                Metadata   =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                RawContent         = proto::ByteString.CopyFromUtf8("raw_content4f67d498"),
                EnableAutoReload   = true,
                LatestReloadStatus = new Document.Types.ReloadStatus(),
            };

            mockGrpcClient.Setup(x => x.GetDocumentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Document>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            DocumentsClient client = new DocumentsClientImpl(mockGrpcClient.Object, null);
            Document        responseCallSettings = await client.GetDocumentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Document responseCancellationToken = await client.GetDocumentAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #27
0
        private async Task SetDocumentAsync()
        {
            if (DocumentName.IsNullOrWhiteSpace())
            {
                DocumentName = Project.DefaultDocumentName;
            }

            DocumentNameWithExtension = DocumentName + "." + Project.Format;

            try
            {
                if (DocumentNameWithExtension.IsNullOrWhiteSpace())
                {
                    Document = await _documentAppService.GetDefaultAsync(
                        new GetDefaultDocumentInput
                    {
                        ProjectId = Project.Id,
                        Version   = Version
                    }
                        );
                }
                else
                {
                    Document = await _documentAppService.GetAsync(
                        new GetDocumentInput
                    {
                        ProjectId = Project.Id,
                        Name      = DocumentNameWithExtension,
                        Version   = Version
                    }
                        );
                }
            }
            catch (DocumentNotFoundException)
            {
                //TODO: Handle it!
                throw;
            }

            ConvertDocumentContentToHtml();
        }
コード例 #28
0
        //TODO: current item should be active => handled by MarkNavbarItemsAsActive?


        private TestMetadata GetDocumentReferenceMetadata(
            string name                      = "name", string version = "1.0",
            string latestVersion             = "1.0", string latestDocumentVersion = "1.0",
            IEnumerable <string>?allVersions = null)
        {
            allVersions ??= new[] { version, latestDocumentVersion, latestVersion }.Distinct().ToArray();

            var documentName     = new DocumentName(name);
            var documentVersion  = NuGetVersion.Parse(version);
            var documentIdentity = new DocumentIdentity(documentName, documentVersion);

            return(new TestMetadata()
            {
                { DocumentReferenceKeys.DocumentName, documentName },
                { DocumentReferenceKeys.DocumentVersion, documentVersion },
                { DocumentReferenceKeys.DocumentIdentity, documentIdentity },
                { DocumentReferenceKeys.DocumentReference, new FullyQualifiedDocumentReference(documentIdentity) },
                { DocumentReferenceKeys.LatestDocumentVersion, NuGetVersion.Parse(latestDocumentVersion) },
                { DocumentReferenceKeys.LatestVersion, NuGetVersion.Parse(latestVersion) },
                {
                    DocumentReferenceKeys.AllDocumentVersions,
                    allVersions
                    .Select(v =>
                    {
                        var version = NuGetVersion.Parse(v);
                        var identity = new DocumentIdentity(documentName, version);
                        return new TestDocument(new TestMetadata()
                        {
                            { DocumentReferenceKeys.DocumentName, documentName },
                            { DocumentReferenceKeys.DocumentVersion, version },
                            { DocumentReferenceKeys.DocumentIdentity, identity },
                            { DocumentReferenceKeys.DocumentReference, new FullyQualifiedDocumentReference(identity) }
                        });
                    })
                    .Cast <IDocument>()
                    .ToArray()
                }
            });
        }
コード例 #29
0
        public void Comparision_of_two_equal_instances_yield_expected_result(string left, string right)
        {
            var leftName  = new DocumentName(left);
            var rightName = new DocumentName(right);

            // instances must be equal to themselves
            Assert.AreEqual(leftName, leftName);
            Assert.AreEqual(rightName, rightName);

#pragma warning disable CS1718 // Comparison made to same variable
            Assert.True(leftName == leftName);
            Assert.False(leftName != leftName);
            Assert.True(rightName == rightName);
            Assert.False(rightName != rightName);
#pragma warning restore CS1718 // Comparison made to same variable

            // hash code must be equal
            Assert.AreEqual(leftName.GetHashCode(), rightName.GetHashCode());

            Assert.AreEqual(leftName, rightName);
            Assert.AreEqual(rightName, leftName);
            Assert.True(leftName.Equals(rightName));
            Assert.True(leftName.Equals((object)rightName));
            Assert.True(rightName.Equals(leftName));
            Assert.True(rightName.Equals((object)leftName));

            var isEqual1    = leftName == rightName;
            var isEqual2    = rightName == leftName;
            var isNotEqual1 = leftName != rightName;
            var isNotEqual2 = rightName != leftName !;

            Assert.True(isEqual1);
            Assert.True(isEqual2);
            Assert.False(isNotEqual1);
            Assert.False(isNotEqual2);
        }
コード例 #30
0
 public override int GetHashCode()
 {
     return(LibraryName.GetHashCode() ^ DocumentName.GetHashCode());
 }