Пример #1
0
        public static void TestSXML(string uri)
        {
            // Prep
            stopwatch = new Stopwatch();
            MemoryStream ms = new MemoryStream(File.ReadAllBytes(uri), 0, Convert.ToInt32(new FileInfo(uri).Length));

            stopwatch.Start();

            // Initialization of a reader
            SimpleDoc reader = new SimpleDoc();

            // Subscribe to events managed by your code here
            // reader.MgmtEvents.StartUpComplete += AcceptStartup;

            // Load the data into the parser
            reader.Load(ms);

            // Take ihe reader for a spin
            reader._testRead();

            stopwatch.Stop();
            reader.Close();
            ms.Close();
            Console.WriteLine("SimpleXML: " + stopwatch.ElapsedMilliseconds.ToString());
        }
        public void DynamicEntityTest_DynamicEntity_Is_Also_An_IEntity()
        {
            //Arrange
            var entity = new SimpleDoc();

            var dynamicEntity = entity.AsDynamic();

            //Act

            //Assert
            Assert.IsInstanceOfType(dynamicEntity, typeof(IEntity));
        }
        public void DynamicEntityTest_Attributes_Passed_To_Dynamic()
        {
            //Arrange
            var entity = new SimpleDoc();

            var dynamicEntity = entity.AsDynamic();

            //Act

            //Assert
            Assert.AreSame(entity.Attributes, dynamicEntity.Attributes);
        }
        public void DynamicEntityTest_Missing_Property_Throws_Exception()
        {
            //Arrange
            var entity = new SimpleDoc();

            var dynamicEntity = entity.AsDynamic();
            //Act
            var tmp = dynamicEntity.thisDoesntExist;

            //Assert
            Assert.Fail("Exception should have been thrown");
        }
        public void DynamicEntityTest_Tab_Accessable_By_Name()
        {
            //Arrange
            var entity = new SimpleDoc();

            var dynamicEntity = entity.AsDynamic();

            //Act

            //Assert
            Assert.IsNotNull(dynamicEntity.textdata);
            Assert.IsTrue(dynamicEntity.textdata.AttributeDefinitions.Count > 0);
            Assert.IsNotNull(dynamicEntity.textdata.bodyText);
        }
        public void DynamicEntityTest_Property_Assignment_Via_Property_Alias()
        {
            //Arrange
            var entity = new SimpleDoc();

            var dynamicEntity = entity.AsDynamic();

            //Act
            dynamicEntity.bodyText = "Hello World";

            //Assert
            Assert.IsNotNull(dynamicEntity.bodyText);
            Assert.IsNotNull(entity.Attributes["bodyText"].Value);
        }
        public void DynamicEntityTest_Hierarchical_Entites_Accessible_By_Convention()
        {
            //Arrange
            var entity = new SimpleDoc();

            entity.DescendentEntities.Add(entity.Id, entity);

            var dynamicEntity = entity.AsDynamic();

            //Act

            //Assert
            Assert.IsNotNull(dynamicEntity.SimpleDocs);
            Assert.AreEqual(0, dynamicEntity.SimepleDocs.Count());
            Assert.AreSame(entity, dynamicEntity.SimpleDocs.First());
        }
Пример #8
0
        public void ShouldWork()
        {
            using (var store = GetDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    SimpleDoc doc = new SimpleDoc()
                    {
                        Id = "TestDoc", Name = "State1"
                    };
                    session.Store(doc);
                    session.SaveChanges();

                    doc.Name = "State2";
                    var changes1 = session.Advanced.WhatChanged();
                    Assert.Equal(DocumentsChanges.ChangeType.FieldChanged, changes1.First().Value.First().Change);
                    Assert.Equal(nameof(SimpleDoc.Name), changes1.First().Value.First().FieldName);
                    Assert.Equal("State1", changes1.First().Value.First().FieldOldValue.ToString());
                    Assert.Equal("State2", changes1.First().Value.First().FieldNewValue.ToString());

                    session.SaveChanges();

                    doc.Name = "State3";
                    var changes2 = session.Advanced.WhatChanged();
                    Assert.Equal(DocumentsChanges.ChangeType.FieldChanged, changes2.First().Value.First().Change);
                    Assert.Equal(nameof(SimpleDoc.Name), changes2.First().Value.First().FieldName);
                    Assert.Equal("State2", changes2.First().Value.First().FieldOldValue.ToString());
                    Assert.Equal("State3", changes2.First().Value.First().FieldNewValue.ToString());

                    session.Advanced.Refresh(doc);
                    doc.Name = "State4";
                    var changes3 = session.Advanced.WhatChanged();
                    Assert.NotEmpty(changes3);
                    Assert.Equal(DocumentsChanges.ChangeType.FieldChanged, changes3.First().Value.First().Change);
                    Assert.Equal(nameof(SimpleDoc.Name), changes3.First().Value.First().FieldName);
                    Assert.Equal("State2", changes3.First().Value.First().FieldOldValue.ToString());
                    Assert.Equal("State4", changes3.First().Value.First().FieldNewValue.ToString());
                }
            }
        }
Пример #9
0
        public void ShouldWork()
        {
            using (var store = GetDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    SimpleDoc doc = new SimpleDoc()
                    {
                        Id = "TestDoc", Name = "State1"
                    };
                    session.Store(doc);

                    string attachment = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
                    var    stream     = new MemoryStream(Encoding.UTF8.GetBytes(attachment));
                    session.Advanced.Attachments.Store(doc, "TestAttachment", stream);

                    session.SaveChanges();
                    var changeVector1 = session.Advanced.GetChangeVectorFor(doc);
                    session.Advanced.Refresh(doc);
                    var changeVector2 = session.Advanced.GetChangeVectorFor(doc);
                    Assert.Equal(changeVector1, changeVector2);
                }
            }
        }
Пример #10
0
        public void DynamicEntityTest_Hierarchical_Entites_Accessible_By_Convention()
        {
            //Arrange
            var entity = new SimpleDoc();
            entity.DescendentEntities.Add(entity.Id, entity);

            var dynamicEntity = entity.AsDynamic();
            //Act

            //Assert
            Assert.IsNotNull(dynamicEntity.SimpleDocs);
            Assert.AreEqual(0, dynamicEntity.SimepleDocs.Count());
            Assert.AreSame(entity, dynamicEntity.SimpleDocs.First());
        }
Пример #11
0
        public void DynamicEntityTest_Tab_Accessable_By_Name()
        {
            //Arrange
            var entity = new SimpleDoc();

            var dynamicEntity = entity.AsDynamic();

            //Act

            //Assert
            Assert.IsNotNull(dynamicEntity.textdata);
            Assert.IsTrue(dynamicEntity.textdata.AttributeDefinitions.Count > 0);
            Assert.IsNotNull(dynamicEntity.textdata.bodyText);
        }
Пример #12
0
        public void DynamicEntityTest_DynamicEntity_Is_Also_An_IEntity()
        {
            //Arrange
            var entity = new SimpleDoc();

            var dynamicEntity = entity.AsDynamic();

            //Act

            //Assert
            Assert.IsInstanceOfType(dynamicEntity, typeof(IEntity));
        }
Пример #13
0
        public void DynamicEntityTest_Attributes_Passed_To_Dynamic()
        {
            //Arrange
            var entity = new SimpleDoc();

            var dynamicEntity = entity.AsDynamic();
            //Act

            //Assert
            Assert.AreSame(entity.Attributes, dynamicEntity.Attributes);
        }
Пример #14
0
        public void DynamicEntityTest_Missing_Property_Throws_Exception()
        {
            //Arrange
            var entity = new SimpleDoc();

            var dynamicEntity = entity.AsDynamic();
            //Act
            var tmp = dynamicEntity.thisDoesntExist;
            //Assert
            Assert.Fail("Exception should have been thrown");
        }
Пример #15
0
        public void DynamicEntityTest_Property_Assignment_Via_Property_Alias()
        {
            //Arrange
            var entity = new SimpleDoc();

            var dynamicEntity = entity.AsDynamic();
            //Act
            dynamicEntity.bodyText = "Hello World";
            
            //Assert
            Assert.IsNotNull(dynamicEntity.bodyText);
            Assert.IsNotNull(entity.Attributes["bodyText"].Value);
        }