Exemplo n.º 1
0
 public DesignModeVersionRangeVM()
 {
     VersionRange = new EditableVersionRange();
     var editableDocument = new EditableDocument() {Language ="es-ES"};
     VersionRange.Documents.Add(editableDocument);
     SelectedDocument = editableDocument;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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");
        }
Exemplo 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));
        }
Exemplo n.º 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;
        }
Exemplo n.º 8
0
 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
     };
 }
Exemplo n.º 9
0
 public static VersionRangeVM VersionRange(EditableVersionRange versionRange)
 {
     return new VersionRangeVM(versionRange);
 }
Exemplo n.º 10
0
 public VersionRangeVM(EditableVersionRange editableVersionRange)
 {
     VersionRange = editableVersionRange;
 }
Exemplo n.º 11
0
 private static void AddDocumentsForDefaultLanguages(EditableVersionRange editableVersionRange)
 {
     editableVersionRange.Documents.Add(new EditableDocument { Language = "es-ES" });
     editableVersionRange.Documents.Add(new EditableDocument { Language = "en-GB" });
 }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
 protected bool Equals(EditableVersionRange other)
 {
     return Documents.SequenceEqual(other.Documents) && Equals(FromVersion, other.FromVersion) && Equals(ToVersion, other.ToVersion);
 }