Example #1
0
        public void GetValue_FromUnAssignedNullableGuidProperty_ReturnsNull()
        {
            var item     = new NullableGuidDummy();
            var property = StructurePropertyTestFactory.GetIdProperty <NullableGuidDummy>();

            var idAccessor    = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue(item);

            Assert.IsTrue(idViaAccessor.IsEmpty);
        }
        public void GetValue_FromUnAssignedNullableGuidProperty_ReturnsNull()
        {
            var item = new GuidDummy();
            var property = TypeInfo<GuidDummy>.GetIdProperty("NullableId");

            var idAccessor = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue<GuidDummy, Guid>(item);

            Assert.IsNull(idViaAccessor);
        }
        public void GetValue_FromUnAssignedNullableIdentityProperty_ReturnsAssignedInt()
        {
            var item = new IdentityDummy();
            var property = TypeInfo<IdentityDummy>.GetIdProperty("NullableId");

            var idAccessor = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue<IdentityDummy, int>(item);

            Assert.IsNull(idViaAccessor);
        }
        public void GetValue_FromAssignedNullableGuidProperty_ReturnsAssignedGuid()
        {
            var id = Guid.Parse("fc47a673-5a5b-419b-9a40-a756591aa7bf");
            var item = new NullableGuidDummy { StructureId = id };
            var property = StructurePropertyTestFactory.GetIdProperty<NullableGuidDummy>();

            var idAccessor = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue(item);

            Assert.AreEqual(id, idViaAccessor.Value);
        }
        public void GetValue_FromAssignedNullableIdentityProperty_ReturnsAssignedInt()
        {
            const int id = 42;
            var item = new IdentityDummy { NullableId = id };
            var property = TypeInfo<IdentityDummy>.GetIdProperty("NullableId");

            var idAccessor = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue<IdentityDummy, int>(item);

            Assert.AreEqual(id, idViaAccessor);
        }
        public void GetValue_FromAssignedLongIdentityProperty_ReturnsAssignedValue()
        {
            var id = 42;
            var item = new BigIdentityDummy { StructureId = id };
            var property = StructurePropertyTestFactory.GetIdProperty<BigIdentityDummy>();

            var idAccessor = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue(item);

            Assert.AreEqual(id, idViaAccessor.Value);
        }
        public void GetValue_FromAssignedNullableGuidProperty_ReturnsAssignedGuid()
        {
            var id = Guid.Parse("fc47a673-5a5b-419b-9a40-a756591aa7bf");
            var item = new GuidDummy { NullableId = id };
            var property = TypeInfo<GuidDummy>.GetIdProperty("NullableId");

            var idAccessor = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue<GuidDummy, Guid>(item);

            Assert.AreEqual(id, idViaAccessor);
        }
        public void GetValue_FromAssignedStringProperty_ReturnsAssignedString()
        {
            var id = "My string id.";
            var item = new StringDummy { StructureId = id };
            var property = StructurePropertyTestFactory.GetIdProperty<StringDummy>();

            var idAccessor = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue(item);

            Assert.AreEqual(id, idViaAccessor.Value);
        }
Example #9
0
        public void SetValue_ToStringProperty_ValueIsAssigned()
        {
            var id   = StructureId.Create("Foo string id");
            var item = new StringDummy();

            var property   = StructurePropertyTestFactory.GetIdProperty <StringDummy>();
            var idAccessor = new IdAccessor(property);

            idAccessor.SetValue(item, id);

            Assert.AreEqual(id.Value, item.StructureId);
        }
Example #10
0
        public void SetValue_of_long_ToNullableLongIdentityProperty_ValueIsAssigned()
        {
            var id   = StructureId.Create((long)42);
            var item = new NullableBigIdentityDummy();

            var property   = StructurePropertyTestFactory.GetIdProperty <NullableBigIdentityDummy>();
            var idAccessor = new IdAccessor(property);

            idAccessor.SetValue(item, id);

            Assert.AreEqual(id.Value, item.StructureId);
        }
Example #11
0
        public void SetValue_ToNullableGuidProperty_ValueIsAssigned()
        {
            var id   = StructureId.Create(Guid.Parse("fc47a673-5a5b-419b-9a40-a756591aa7bf"));
            var item = new NullableGuidDummy();

            var property   = StructurePropertyTestFactory.GetIdProperty <NullableGuidDummy>();
            var idAccessor = new IdAccessor(property);

            idAccessor.SetValue(item, id);

            Assert.AreEqual(id.Value, item.StructureId);
        }
Example #12
0
        public void GetValue_FromAssignedNullableGuidProperty_ReturnsAssignedGuid()
        {
            var id   = Guid.Parse("fc47a673-5a5b-419b-9a40-a756591aa7bf");
            var item = new NullableGuidDummy {
                StructureId = id
            };
            var property = StructurePropertyTestFactory.GetIdProperty <NullableGuidDummy>();

            var idAccessor    = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue(item);

            Assert.AreEqual(id, idViaAccessor.Value);
        }
Example #13
0
        public void GetValue_FromAssignedStringProperty_ReturnsAssignedString()
        {
            var id   = "My string id.";
            var item = new StringDummy {
                StructureId = id
            };
            var property = StructurePropertyTestFactory.GetIdProperty <StringDummy>();

            var idAccessor    = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue(item);

            Assert.AreEqual(id, idViaAccessor.Value);
        }
Example #14
0
        public void GetValue_FromAssignedNullableLongIdentityProperty_ReturnsAssignedValue()
        {
            var id   = 42;
            var item = new NullableBigIdentityDummy {
                StructureId = id
            };
            var property = StructurePropertyTestFactory.GetIdProperty <NullableBigIdentityDummy>();

            var idAccessor    = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue(item);

            Assert.AreEqual(id, idViaAccessor.Value);
        }
Example #15
0
        public Settings2(string databaseName, Connection connection, ILogger logger = null)
        {
            Logger = logger ?? new NullLogger();

            //global
            IdAccessor       = new IdAccessor();
            IdManager        = new ShortGuidIdManager();
            RevisionAccessor = new RevisionAccessor();
            TypeManager      = new TypeManager();

            Serializer = new Serializer(IdAccessor, RevisionAccessor);

            //query serializer
            var settings = new JsonSerializerSettings()
            {
                TypeNameHandling  = TypeNameHandling.None,
                NullValueHandling = NullValueHandling.Ignore,
                ContractResolver  =
                    new CamelCasePropertyNamesContractResolver()
                {
                    NamingStrategy = new LocalCamelCaseNamingStrategy(true)
                }
            };

            settings.Converters.Add(new OrderEnumConverter());
            QuerySerializer = new Serializer(settings);

            CouchDb                = new CouchDb(databaseName, connection, Serializer, QuerySerializer, Logger);
            QueryFactory           = new QueryFactory(TypeManager, IdAccessor);
            TransactionCoordinator = new TransactionCoordinator(CouchDb, IdAccessor, RevisionAccessor);

            LoadPipeline   = new LoadPipeline(CouchDb, IdManager, IdAccessor, RevisionAccessor);
            CommitPipeline = new CommitPipeline(CouchDb, IdManager, RevisionAccessor, TransactionCoordinator);
            QueryPipeline  = new QueryPipeline(CouchDb, IdManager, IdAccessor, RevisionAccessor);

            Hash = new ToLowerPassThroughHash();
        }
Example #16
0
        internal static IStructureSchema Stub(Type structureType, bool generateIdAccessor = false, string[] indexAccessorsPaths = null)
        {
            var schemaStub = new Mock <IStructureSchema>();

            schemaStub.Setup(s => s.Name).Returns(structureType.Name);

            if (generateIdAccessor)
            {
                var idAccessor = new IdAccessor(StructurePropertyTestFactory.GetIdProperty(structureType));
                schemaStub.Setup(s => s.IdAccessor).Returns(idAccessor);
            }

            if (indexAccessorsPaths != null)
            {
                var indexAccessors = indexAccessorsPaths.Select(path =>
                {
                    var property = StructurePropertyTestFactory.GetPropertyByPath(structureType, path);
                    return(new IndexAccessor(property, DataTypeConverter.Convert(property)));
                });
                schemaStub.Setup(s => s.IndexAccessors).Returns(indexAccessors.ToArray);
            }

            return(schemaStub.Object);
        }
 public Request(IdAccessor id, SingleInstance s)
 {
     _id = id;
     _s = s;
 }
        public void SetValue_ToGuidProperty_ValueIsAssigned()
        {
            var id = Guid.Parse("fc47a673-5a5b-419b-9a40-a756591aa7bf");
            var item = new GuidDummy();

            var property = TypeInfo<GuidDummy>.GetIdProperty("Id");
            var idAccessor = new IdAccessor(property);
            idAccessor.SetValue(item, id);

            Assert.AreEqual(id, item.Id);
        }
        public void GetValue_FromUnAssignedNullableLongIdentityProperty_ReturnsNull()
        {
            var item = new NullableBigIdentityDummy();
            var property = StructurePropertyTestFactory.GetIdProperty<NullableBigIdentityDummy>();

            var idAccessor = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue(item);

            Assert.IsFalse(idViaAccessor.HasValue);
        }
        public void SetValue_ToNullableGuidProperty_ValueIsAssigned()
        {
            var id = StructureId.Create(Guid.Parse("fc47a673-5a5b-419b-9a40-a756591aa7bf"));
            var item = new NullableGuidDummy();

            var property = StructurePropertyTestFactory.GetIdProperty<NullableGuidDummy>();
            var idAccessor = new IdAccessor(property);
            idAccessor.SetValue(item, id);

            Assert.AreEqual(id.Value, item.StructureId);
        }
        public void SetValue_of_long_ToNullableLongIdentityProperty_ValueIsAssigned()
        {
            var id = StructureId.Create((long)42);
            var item = new NullableBigIdentityDummy();

            var property = StructurePropertyTestFactory.GetIdProperty<NullableBigIdentityDummy>();
            var idAccessor = new IdAccessor(property);
            idAccessor.SetValue(item, id);

            Assert.AreEqual(id.Value, item.StructureId);
        }
        public void GetValue_FromUnAssignedNullableGuidProperty_ReturnsNull()
        {
            var item = new NullableGuidDummy();
            var property = StructurePropertyTestFactory.GetIdProperty<NullableGuidDummy>();

            var idAccessor = new IdAccessor(property);
            var idViaAccessor = idAccessor.GetValue(item);

            Assert.IsTrue(idViaAccessor.IsEmpty);
        }
        public void SetValue_ToNullableIntProperty_ValueIsAssigned()
        {
            const int id = 42;
            var item = new IdentityDummy();

            var property = TypeInfo<IdentityDummy>.GetIdProperty("NullableId");
            var idAccessor = new IdAccessor(property);
            idAccessor.SetValue(item, id);

            Assert.AreEqual(id, item.NullableId);
        }
        public void SetValue_ToStringProperty_ValueIsAssigned()
        {
            var id = StructureId.Create("Foo string id");
            var item = new StringDummy();

            var property = StructurePropertyTestFactory.GetIdProperty<StringDummy>();
            var idAccessor = new IdAccessor(property);
            idAccessor.SetValue(item, id);

            Assert.AreEqual(id.Value, item.StructureId);
        }