Ejemplo n.º 1
0
        public void CompareTo_WhenEqualNonNullableAndNullableLongs_Returns0()
        {
            var x = StructureId.Create((long?)42);
            var y = StructureId.Create((long)42);

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 2
0
        public void CompareTo_WhenStringsAreNull_Returns0()
        {
            var x = StructureId.Create((string)null);
            var y = StructureId.Create((string)null);

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 3
0
        public void CompareTo_WhenStringsDifferOnCasing_Returns0()
        {
            var x = StructureId.Create("foo");
            var y = StructureId.Create("FOO");

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 4
0
        public void CompareTo_WhenEqualStrings_Returns0()
        {
            var x = StructureId.Create("foo");
            var y = StructureId.Create("foo");

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 5
0
        public void CompareTo_WhenLongXisGreaterThanY_Returns1()
        {
            var x = StructureId.Create((long)20);
            var y = StructureId.Create((long)10);

            Assert.AreEqual(1, x.CompareTo(y));
        }
Ejemplo n.º 6
0
        public void CompareTo_WhenIntXisLessThanY_ReturnsMinus1()
        {
            var x = StructureId.Create(10);
            var y = StructureId.Create(20);

            Assert.AreEqual(-1, x.CompareTo(y));
        }
Ejemplo n.º 7
0
        public void CompareTo_WhenStringXisGreaterThanY_Returns1()
        {
            var x = StructureId.Create("b");
            var y = StructureId.Create("a");

            Assert.AreEqual(1, x.CompareTo(y));
        }
Ejemplo n.º 8
0
        public void GetSmallest_WhenXisGreaterThanY_ReturnsX()
        {
            var x = StructureId.Create(20);
            var y = StructureId.Create(10);

            Assert.AreEqual(y, StructureId.GetSmallest(x, y));
        }
 private IEnumerable <IStructureId> GenerateIds(int numOfIds)
 {
     for (var c = 0; c < numOfIds; c++)
     {
         yield return(StructureId.Create(SequentialGuid.New()));
     }
 }
Ejemplo n.º 10
0
        public void CompareTo_WhenEqualNullableInts_Returns0()
        {
            var x = StructureId.Create((int?)42);
            var y = StructureId.Create((int?)42);

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 11
0
        public void CompareTo_WhenEqualNullableLongsAreNull_Returns0()
        {
            var x = StructureId.Create((long?)null);
            var y = StructureId.Create((long?)null);

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 12
0
        public void CompareTo_WhenEqualNonNullableAndNullableGuids_Returns0()
        {
            var v = Guid.Parse("E72A0240-4B05-4678-B1DD-8CCBA10F8CA2");
            var x = StructureId.Create((Guid?)v);
            var y = StructureId.Create(v);

            Assert.AreEqual(0, x.CompareTo(y));
        }
Ejemplo n.º 13
0
        public void CompareTo_WhenDifferentIdTypes_ThrowsException()
        {
            var x = StructureId.Create((int?)42);
            var y = StructureId.Create((long?)42);

            var ex = Assert.Throws <SisoDbException>(() => x.CompareTo(y));

            Assert.AreEqual(ExceptionMessages.StructureId_CompareTo_DifferentIdTypes, ex.Message);
        }
Ejemplo n.º 14
0
        public void Set_WhenFromIsNull_FromBecomesNewId()
        {
            var from     = StructureId.Create(1);
            var interval = new StructureIdInterval();

            interval.Set(from);

            Assert.AreEqual(from, interval.From);
        }
Ejemplo n.º 15
0
        public void Equals_WhenDifferentName_ReturnsFalse()
        {
            var          structureId = StructureId.Create(Guid.Parse("06E2FC67-AB9F-4E65-A2C8-5FC897597887"));
            const string thevalue    = "TheValue";

            var structure1 = new StructureIndex(structureId, "TheName", thevalue, thevalue.GetType(), _converter.Convert(CreateProperty(thevalue.GetType())));
            var structure2 = new StructureIndex(structureId, "TheOtherName", thevalue, thevalue.GetType(), _converter.Convert(CreateProperty(thevalue.GetType())));

            Assert.AreNotEqual(structure1, structure2);
        }
Ejemplo n.º 16
0
        public void Equals_WhenDifferentValue_ReturnsFalse()
        {
            var structureId  = StructureId.Create(Guid.Parse("06E2FC67-AB9F-4E65-A2C8-5FC897597887"));
            var dataType     = typeof(string);
            var dataTypeCode = _converter.Convert(CreateProperty(dataType));

            var structure1 = new StructureIndex(structureId, "TheName", "TheValue", dataType, dataTypeCode);
            var structure2 = new StructureIndex(structureId, "TheName", "OtherValue", dataType, dataTypeCode);

            Assert.AreNotEqual(structure1, structure2);
        }
Ejemplo n.º 17
0
        public void Equals_WhenDifferentGuidStructureId_ReturnsFalse()
        {
            var          structureId1 = StructureId.Create(Guid.Parse("06E2FC67-AB9F-4E65-A2C8-5FC897597887"));
            var          structureId2 = StructureId.Create(Guid.Parse("14D4D3EC-6E1E-4839-ACC7-EA3B4653CF96"));
            const string thevalue     = "TheValue";

            var structure1 = new StructureIndex(structureId1, "TheName", thevalue, thevalue.GetType(), _converter.Convert(CreateProperty(thevalue.GetType())));
            var structure2 = new StructureIndex(structureId2, "TheName", thevalue, thevalue.GetType(), _converter.Convert(CreateProperty(thevalue.GetType())));

            Assert.AreNotEqual(structure1, structure2);
        }
Ejemplo n.º 18
0
        public void Create_WhenLongAsString_WithSpecificIdType_ValuesAreReflected()
        {
            long value = 42;

            var id = StructureId.Create(value.ToString(), StructureIdTypes.BigIdentity);

            Assert.IsFalse(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(long), id.DataType);
            Assert.AreEqual(StructureIdTypes.BigIdentity, id.IdType);
        }
Ejemplo n.º 19
0
        public virtual IStructureId[] Generate(IStructureSchema structureSchema, int numOfIds)
        {
            var structureIds = new IStructureId[numOfIds];

            for (var c = 0; c < structureIds.Length; c++)
            {
                structureIds[c] = StructureId.Create(GenerateComb());
            }

            return(structureIds);
        }
Ejemplo n.º 20
0
        public void Create_WhenGuidAsString_WithSpecificIdType_ValuesAreReflected()
        {
            Guid value = Guid.Parse("86141ed0-7000-43a0-8136-93c423573574");

            var id = StructureId.Create(value.ToString(), StructureIdTypes.Guid);

            Assert.IsFalse(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(Guid), id.DataType);
            Assert.AreEqual(StructureIdTypes.Guid, id.IdType);
        }
Ejemplo n.º 21
0
        public void Create_WhenGuidAsObject_WithSpecificIdType_ValuesAreReflected()
        {
            object value = Guid.Parse("ec20922b-195e-4787-89a8-68bc2b4c0fe6");

            var id = StructureId.Create(value, StructureIdTypes.Guid);

            Assert.IsFalse(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(Guid), id.DataType);
            Assert.AreEqual(StructureIdTypes.Guid, id.IdType);
        }
Ejemplo n.º 22
0
        public void Create_WhenNullStringAsString_WithSpecificIdType_ValuesAreReflected()
        {
            string value = null;

            var id = StructureId.Create(value, StructureIdTypes.String);

            Assert.IsTrue(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(string), id.DataType);
            Assert.AreEqual(StructureIdTypes.String, id.IdType);
        }
Ejemplo n.º 23
0
        public void Create_WhenNullableGuidAsString_WithSpecificIdType_ValuesAreReflected()
        {
            Guid?value = null;

            var id = StructureId.Create(value.ToString(), StructureIdTypes.Guid);

            Assert.IsTrue(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(Guid?), id.DataType);
            Assert.AreEqual(StructureIdTypes.Guid, id.IdType);
        }
Ejemplo n.º 24
0
        public void Create_WhenNullableGuidNotNull_ValuesAreReflected()
        {
            Guid?value = Guid.Parse("46C72168-C637-416D-9736-751E2A17028A");

            var id = StructureId.Create(value);

            Assert.IsFalse(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(Guid?), id.DataType);
            Assert.AreEqual(StructureIdTypes.Guid, id.IdType);
        }
Ejemplo n.º 25
0
        public void Create_WhenString_ValuesAreReflected()
        {
            var value = "My string id.";

            var id = StructureId.Create(value);

            Assert.IsFalse(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(string), id.DataType);
            Assert.AreEqual(StructureIdTypes.String, id.IdType);
        }
Ejemplo n.º 26
0
        public void Create_WhenNullableGuidBeingNull_ValuesAreReflected()
        {
            Guid?value = null;

            var id = StructureId.Create(value);

            Assert.IsTrue(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(Guid?), id.DataType);
            Assert.AreEqual(StructureIdTypes.Guid, id.IdType);
        }
Ejemplo n.º 27
0
        public void Create_WhenNullableIntNotNull_ValuesAreReflected()
        {
            int?value = int.MaxValue;

            var id = StructureId.Create(value);

            Assert.IsFalse(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(int?), id.DataType);
            Assert.AreEqual(StructureIdTypes.Identity, id.IdType);
        }
Ejemplo n.º 28
0
        public void Create_WhenLong_ValuesAreReflected()
        {
            var value = long.MaxValue;

            var id = StructureId.Create(value);

            Assert.IsFalse(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(long), id.DataType);
            Assert.AreEqual(StructureIdTypes.BigIdentity, id.IdType);
        }
Ejemplo n.º 29
0
        public void Create_WhenStringAsObject_WithSpecificIdType_ValuesAreReflected()
        {
            object value = "keyA";

            var id = StructureId.Create(value, StructureIdTypes.String);

            Assert.IsFalse(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(string), id.DataType);
            Assert.AreEqual(StructureIdTypes.String, id.IdType);
        }
Ejemplo n.º 30
0
        public void Create_WhenNullableLongBeingNull_ValuesAreReflected()
        {
            long?value = null;

            var id = StructureId.Create(value);

            Assert.IsTrue(id.IsEmpty);
            Assert.AreEqual(value, id.Value);
            Assert.AreEqual(typeof(long?), id.DataType);
            Assert.AreEqual(StructureIdTypes.BigIdentity, id.IdType);
        }