コード例 #1
0
ファイル: VersionRangeVM.cs プロジェクト: RonnyAnc/Papyrus
 public DesignModeVersionRangeVM()
 {
     VersionRange = new EditableVersionRange();
     var editableDocument = new EditableDocument() {Language ="es-ES"};
     VersionRange.Documents.Add(editableDocument);
     SelectedDocument = editableDocument;
 }
コード例 #2
0
ファイル: VersionRangesVM.cs プロジェクト: RonnyAnc/Papyrus
 private static EditableVersionRange DefaultEditableVersionRange()
 {
     var editableVersionRange = new EditableVersionRange();
     var spanishEmptyDocument = new EditableDocument { Language = "es-ES" };
     var englishEmptyDocument = new EditableDocument {Language = "en-GB"};
     editableVersionRange.Documents.Add(spanishEmptyDocument);
     editableVersionRange.Documents.Add(englishEmptyDocument);
     return editableVersionRange;
 }
コード例 #3
0
 private EditableTopic ATopicContainingADescendentVersionRange() {
     var versionRange = new EditableVersionRange {
         FromVersion = new ProductVersion("Any", "Any", DateTime.Today),
         ToVersion = new ProductVersion("Another", "Another", DateTime.Today.AddDays(-2))
     };
     var topic = new EditableTopic {
         Product = new DisplayableProduct(),
         TopicId = "AnyId",
         VersionRanges = new ObservableCollection<EditableVersionRange> { versionRange }
     };
     return topic;
 }
コード例 #4
0
 private static EditableTopic ATopicContainingADocumentWithEmptyTitle() {
     var versionRange = new EditableVersionRange {
         FromVersion = new ProductVersion("Any", "Any", DateTime.Today.AddDays(-2)),
         ToVersion = new ProductVersion("Another", "Another", DateTime.Today)
     };
     versionRange.Documents.Add(new EditableDocument {Title = ""});
     var versionRanges = new ObservableCollection<EditableVersionRange> {
         versionRange
     };
     var topic = new EditableTopic {
         Product = new DisplayableProduct(),
         TopicId = "AnyId",
         VersionRanges = versionRanges
     };
     return topic;
 }
コード例 #5
0
        public void fail_when_try_to_create_a_topic_with_version_ranges_that_collide()
        {
            var topic = new Topic(anyProductId);
            topic.AddVersionRange(anyVersionRange);
            topic.AddVersionRange(anyVersionRange);
            var anyEditableVersionRange = new EditableVersionRange
            {
                FromVersion = new ProductVersion("Any", "2.0", DateTime.Today),
                ToVersion = new ProductVersion("Any", "3.0", DateTime.Today)
            };
            var anyListToRepresentConflictedVersionRanges = new List<Collision> {new Collision(
                anyEditableVersionRange, anyEditableVersionRange
            )};
            collisionDetector.CollisionsFor(topic).Returns(Task.FromResult(anyListToRepresentConflictedVersionRanges));

            Func<Task> createTopic = async () => await topicService.Create(topic);
            
            createTopic.ShouldThrow<VersionRangesCollisionException>()
                .WithMessage("(2.0 -- 3.0) collide with (2.0 -- 3.0)\n");
        }
コード例 #6
0
        public void convert_itself_to_a_topic()
        {
            var opportunity = new DisplayableProduct
            {
                ProductId = "OpportunityId",
                ProductName = "Opportunity"
            };
            var editableVersionRange = new EditableVersionRange
            {
                FromVersion = new ProductVersion("FirstVersionId", "1.0", DateTime.Today.AddDays(-2)),
                ToVersion = new ProductVersion("SecondVersionId", "2.0", DateTime.Today),
            };
            var editableDocument = new EditableDocument
            {
                Title = "Título",
                Description = "Descripción",
                Content = "Contenido",
                Language = "es-ES"
            };
            editableVersionRange.Documents.Add(editableDocument);
            var editableVersionRanges = new ObservableCollection<EditableVersionRange>
            {
                editableVersionRange
            };
            var editableTopic = new EditableTopic
            {
                Product = opportunity,
                TopicId = "TopicId",
                VersionRanges = editableVersionRanges
            };

            var topic = editableTopic.ToTopic();

            topic.ProductId.Should().Be("OpportunityId");
            topic.TopicId.Should().Be("TopicId");
            topic.VersionRanges.Should().HaveCount(1);
            var versionRange = topic.VersionRanges.First();
            versionRange.FromVersionId.Should().Be(editableVersionRange.FromVersion.VersionId);
            versionRange.ToVersionId.Should().Be(editableVersionRange.ToVersion.VersionId);
            versionRange.Documents.Should().HaveCount(1);
            versionRange.Documents["es-ES"].ShouldBeEquivalentTo(editableDocument, options => options.Excluding(d => d.DocumentId));
        }
コード例 #7
0
        private EditableVersionRange MapToEditableVersionRange(dynamic versionRange) {
            var fromVersion = versionRange.FromVersion;
            var toVersion = versionRange.ToVersion;
            var editableVersionRange = new EditableVersionRange() {
                FromVersion = versionRange.FromVersion,
                ToVersion = versionRange.ToVersion
            };

            foreach (var editableDocument in versionRange.Documents) {
                editableVersionRange.Documents.Add(editableDocument);
            }
            return editableVersionRange;
        }
コード例 #8
0
ファイル: VersionRangesVM.cs プロジェクト: RonnyAnc/Papyrus
 public DesignModeVersionRangesVM()
 {
     var anyDocument = new EditableDocument
     {
         Title = "Título",
         Description = "Descripción",
         Content = "Contenido",
         Language = "es-ES"
     };
     var anyEditableVersionRange = new EditableVersionRange
     {
         FromVersion = new ProductVersion("AnyId", "1.0", DateTime.Today),
         ToVersion = new ProductVersion("AnyId", "2.0", DateTime.Today),
     };
     anyEditableVersionRange.Documents.Add(anyDocument);
     var anotherVersionRange = new EditableVersionRange
     {
         FromVersion = new ProductVersion("AnyId", "3.0", DateTime.Today),
         ToVersion = new ProductVersion("AnyId", "4.0", DateTime.Today)
     };
     anotherVersionRange.Documents.Add(anyDocument);
     VersionRanges = new ObservableCollection<EditableVersionRange>
     {
         anyEditableVersionRange,
         anotherVersionRange
     };
 }
コード例 #9
0
ファイル: ViewModelsFactory.cs プロジェクト: RonnyAnc/Papyrus
 public static VersionRangeVM VersionRange(EditableVersionRange versionRange)
 {
     return new VersionRangeVM(versionRange);
 }
コード例 #10
0
ファイル: VersionRangeVM.cs プロジェクト: RonnyAnc/Papyrus
 public VersionRangeVM(EditableVersionRange editableVersionRange)
 {
     VersionRange = editableVersionRange;
 }
コード例 #11
0
ファイル: TopicsGridVM.cs プロジェクト: RonnyAnc/Papyrus
 private static void AddDocumentsForDefaultLanguages(EditableVersionRange editableVersionRange)
 {
     editableVersionRange.Documents.Add(new EditableDocument { Language = "es-ES" });
     editableVersionRange.Documents.Add(new EditableDocument { Language = "en-GB" });
 }
コード例 #12
0
ファイル: TopicsGridVM.cs プロジェクト: RonnyAnc/Papyrus
 private async Task<EditableVersionRange> DefaultVersionRange()
 {
     var fullVersionRange = await productRepository.GetFullVersionRangeForProduct(SelectedProduct.ProductId);
     var editableVersionRange = new EditableVersionRange
     {
         FromVersion = await productRepository.GetVersion(fullVersionRange.FirstVersionId),
         ToVersion = await productRepository.GetVersion(fullVersionRange.LatestVersionId)
     };
     AddDocumentsForDefaultLanguages(editableVersionRange);
     return editableVersionRange;
 }
コード例 #13
0
 protected bool Equals(EditableVersionRange other)
 {
     return Documents.SequenceEqual(other.Documents) && Equals(FromVersion, other.FromVersion) && Equals(ToVersion, other.ToVersion);
 }