Exemple #1
0
        public void SetDefaultValue_ShouldAssign_NameToDefault()
        {
            var testObject = new DefaultsObject4();

            testObject.Should().NotBeNull();
            testObject.Name.Should().Be("Simple");

            bool?result    = null;
            var  exception = Record.Exception(() => result = testObject.SetDefaultValue(nameof(DefaultsObject4.Name)));

            exception.Should().BeNull();
            result.Should().BeTrue();
            testObject.Name.Should().Be("Default");
        }
Exemple #2
0
        public void SetDefaultValue_ShouldAssign_NullableProperty()
        {
            var testObject = new DefaultsObject4();

            testObject.Should().NotBeNull();
            testObject.State.Should().BeFalse();

            bool?result    = null;
            var  exception = Record.Exception(() => result = testObject.SetDefaultValue(nameof(DefaultsObject4.State)));

            exception.Should().BeNull();
            result.Should().BeTrue();
            testObject.State.Should().NotHaveValue();
        }
Exemple #3
0
        public void SetDefaultValue_ShouldAssign_DeltaToDefault()
        {
            var testObject = new DefaultsObject4();

            testObject.Should().NotBeNull();
            testObject.Delta.Should().Be(0);

            bool?result    = null;
            var  exception = Record.Exception(() => result = testObject.SetDefaultValue <short>(nameof(DefaultsObject4.Delta)));

            exception.Should().BeNull();
            result.Should().BeTrue();
            testObject.Delta.Should().Be(400);
        }
Exemple #4
0
        public void SetDefaultValue_ShouldKeep_DeltaWithoutDefault()
        {
            var testObject = new DefaultsObject4();

            testObject.Should().NotBeNull();
            testObject.DeltaWithoutDefault.Should().Be(50);

            bool?result    = null;
            var  exception = Record.Exception(() => result = testObject.SetDefaultValue <short>(nameof(DefaultsObject4.DeltaWithoutDefault)));

            exception.Should().BeNull();
            result.Should().BeFalse();
            testObject.DeltaWithoutDefault.Should().Be(50);
        }
Exemple #5
0
        public void SetDefaultValue_ShouldAssign_PrivateCountToDefault()
        {
            var testObject = new DefaultsObject4();

            testObject.Should().NotBeNull();
            testObject.PrivateCount.Should().Be(0);

            bool?result    = null;
            var  exception = Record.Exception(() => result = testObject.SetDefaultValue(nameof(DefaultsObject4.PrivateCount)));

            exception.Should().BeNull();
            result.Should().BeTrue();
            testObject.PrivateCount.Should().Be(300);
        }