Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 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");
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 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");
        }
Exemplo n.º 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);
        }
Exemplo n.º 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");
        }
Exemplo n.º 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();
        }
Exemplo n.º 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);
        }