Exemple #1
0
        public void Count_Fact()
        {
            var fake = new FakeEntity(1, "Fact");

            var ctx = new PropertyContext(fake);

            ctx.SetProperty(FactEnum.Fact1, "Fact #1");
            ctx.SetProperty(FactEnum.Fact2, "Fact #2");

            ctx.Count.Should().Be(2);
        }
Exemple #2
0
        public void PropertyContext_SetProperty_Exists_Volatile_Test()
        {
            const int firstValue  = 5;
            const int secondValue = 10;
            var       target      = new PropertyContext(null);

            target.SetProperty("Test", firstValue, PropertyTypeOptions.Volatile);
            target.GetProperty <int>("Test").Should().Be(firstValue);

            target.SetProperty("Test", secondValue);
            target.GetProperty <int>("Test").Should().Be(secondValue);
        }
Exemple #3
0
        public void PropertyContext_GetPropertyCount_Test()
        {
            var target = new PropertyContext(null);

            target.SetProperty("Test", 1);
            target.SetProperty("Tester", 2);

            const int expected = 2;
            var       actual   = target.Count;

            actual.Should().Be(expected);
        }
Exemple #4
0
        public void PropertyKeys_Fact()
        {
            var fake = new FakeEntity(1, "Fact");

            var ctx = new PropertyContext(fake);

            ctx.SetProperty(FactEnum.Fact1, "Fact #1");
            ctx.SetProperty(FactEnum.Fact2, "Fact #2");

            var keys = ctx.PropertyKeys;

            keys.Should().NotBeNull();
            keys.Count().Should().Be(2);
            keys.Contains("Fact1").Should().BeTrue();
            keys.Contains("Fact2").Should().BeTrue();
        }
Exemple #5
0
        public void SetProperty_StringName_Volatile_SetExisting_Fact()
        {
            var fake = new FakeEntity(1, "Fact");

            var ctx = new PropertyContext(fake);

            ctx.SetProperty("NullProperty", "Nothing", PropertyTypeOptions.Volatile);

            var result = ctx.GetProperty <string>("NullProperty");

            result.Should().Be("Nothing");

            ctx.SetProperty("NullProperty", "Still Nothing");

            result = ctx.GetProperty <string>("NullProperty");
            result.Should().Be("Still Nothing");
        }
Exemple #6
0
        public void PropertyContext_GetPropertyKeys_Test()
        {
            var target = new PropertyContext(null);

            target.SetProperty("Test", 1);
            target.SetProperty("Tester", 2);

            const int expected = 2;
            var       actual   = target.PropertyKeys;

            if (actual == null)
            {
                throw new Exception("Object list is null");
            }
            var keyList = new List <string>(actual);

            keyList.Count.Should().Be(expected);
        }
Exemple #7
0
        public void PropertyContext_GetPropertyBits_NotFound_Test()
        {
            var target = new PropertyContext(null);

            target.SetProperty("Test", 1);

            var actual = target.GetPropertyBits("Tester");

            actual.Should().BeEmpty();
        }
Exemple #8
0
        public void PropertyContext_GetBooleanProperty_Test()
        {
            var target = new PropertyContext(null);

            target.SetProperty("Test", true);

            const bool expected = true;
            var        actual   = target.GetProperty <bool>("Test");

            actual.Should().Be(expected);
        }
Exemple #9
0
        public void PropertyContext_GetIntProperty_Test()
        {
            var target = new PropertyContext(null);

            target.SetProperty("Test", 512);

            const int expected = 512;
            var       actual   = target.GetProperty <int>("Test");

            actual.Should().Be(expected);
        }
Exemple #10
0
        public void PropertyContext_GetPropertyBits_Found_Test()
        {
            var target = new PropertyContext(null);

            target.SetProperty("Test", 1, PropertyTypeOptions.Persistable | PropertyTypeOptions.Visible | PropertyTypeOptions.Volatile);

            const string expected = "pvi";
            var          actual   = target.GetPropertyBits("Test");

            actual.Should().Be(expected);
        }
Exemple #11
0
        public void PropertyContext_RemoveProperty_Found_Test()
        {
            var target = new PropertyContext(null);

            target.SetProperty("Test", 1);

            const bool expected = true;
            var        actual   = target.RemoveProperty("Test");

            actual.Should().Be(expected);
        }
Exemple #12
0
        public void PropertyContext_IsVisible_Found_Test()
        {
            var target = new PropertyContext(null);

            target.SetProperty("Test", 1, PropertyTypeOptions.Visible);

            const bool expected = true;
            var        actual   = target.IsVisible("Test");

            actual.Should().Be(expected);
        }
Exemple #13
0
        public void PropertyContext_IsVisible_NotFound_Test()
        {
            var target = new PropertyContext(null);

            target.SetProperty("Test", 1);

            const bool expected = false;
            var        actual   = target.IsVisible("Tester");

            actual.Should().Be(expected);
        }
Exemple #14
0
        public void PropertyContext_GetLongProperty_Test()
        {
            var target = new PropertyContext(null);

            target.SetProperty("Test", 10000000000000);

            const long expected = 10000000000000;
            var        actual   = target.GetProperty <long>("Test");

            actual.Should().Be(expected);
        }
Exemple #15
0
        public void PropertyContext_HasProperty_Test()
        {
            var target = new PropertyContext(null);

            target.SetProperty("Test", new object());

            const bool expected = true;
            var        actual   = target.HasProperty("Test");

            actual.Should().Be(expected);
        }
Exemple #16
0
        public void PropertyContext_GetStringProperty_Test()
        {
            var target = new PropertyContext(null);

            target.SetProperty("Test", "Testing");

            const string expected = "Testing";
            var          actual   = target.GetProperty <string>("Test");

            actual.Should().Be(expected);
        }
Exemple #17
0
        public void HasProperty_Fact()
        {
            var fake = new FakeEntity(1, "Fact");

            var ctx = new PropertyContext(fake);

            ctx.SetProperty(FactEnum.Fact1, "Nothing");

            var result = ctx.HasProperty("Fact1");

            result.Should().BeTrue();
        }
Exemple #18
0
        public void IsPersistable_True_Fact()
        {
            var fake = new FakeEntity(1, "Fact");

            var ctx = new PropertyContext(fake);

            ctx.SetProperty(FactEnum.Fact1, "Nothing", PropertyTypeOptions.Persistable);

            var result = ctx.IsPersistable("Fact1");

            result.Should().BeTrue();
        }
Exemple #19
0
        public void SetProperty_Enum_NoOptions_Fact()
        {
            var fake = new FakeEntity(1, "Fact");

            var ctx = new PropertyContext(fake);

            ctx.SetProperty(FactEnum.Fact1, "Nothing");

            var result = ctx.GetProperty <string>("Fact1");

            result.Should().Be("Nothing");
        }
Exemple #20
0
        public void PropertyContext_GetProperty_Test()
        {
            var target = new PropertyContext(null);

            var expected = new object();

            target.SetProperty("Test", expected);

            var actual = target.GetProperty <object>("Test");

            actual.Should().Be(expected);
        }
Exemple #21
0
        public void SetProperty_StringName_NoOptions_Fact()
        {
            var fake = new FakeEntity(1, "Fact");

            var ctx = new PropertyContext(fake);

            ctx.SetProperty("NullProperty", "Nothing");

            var result = ctx.GetProperty <string>("NullProperty");

            result.Should().Be("Nothing");
        }
Exemple #22
0
        public void IsVolatile_False_Fact()
        {
            var fake = new FakeEntity(1, "Fact");

            var ctx = new PropertyContext(fake);

            ctx.SetProperty(FactEnum.Fact1, "Nothing");

            var result = ctx.IsVolatile("Fact1");

            result.Should().BeFalse();
        }
Exemple #23
0
        public void GetPropertyBits_Fact(PropertyTypeOptions options, string expectedValue)
        {
            var fake = new FakeEntity(1, "Fact");

            var ctx = new PropertyContext(fake);

            ctx.SetProperty(FactEnum.Fact1, "Nothing", options);

            var result = ctx.GetPropertyBits("Fact1");

            result.Should().Be(expectedValue);
        }