示例#1
0
        public void Freeze_WhenTableNotFrozenYet_ReturnsTrue()
        {
            using (var scenario = MultiLevelTableScenario.Setup())
            {
                // Act
                var r = scenario.Table.Freeze();

                // Assert
                r.Should().Be(true);
            }
        }
示例#2
0
        public void Freeze_FreezesRecursive()
        {
            using (var scenario = MultiLevelTableScenario.Setup())
            {
                // Act
                scenario.Table.Freeze();

                // Assert
                Action a = () => scenario.SubTable.Add("new", (long)0);
                a.ShouldThrow <InvalidOperationException>().WithMessage("*frozen*");
            }
        }
示例#3
0
        public void Freeze_FreezesCurrentTable()
        {
            using (var scenario = MultiLevelTableScenario.Setup())
            {
                // Act
                scenario.Table.Freeze();

                // Assert
                Action a = () => scenario.Table.AddValue("new", 0.0);
                a.ShouldThrow <InvalidOperationException>().WithMessage("*frozen*");
            }
        }
示例#4
0
        public void Freeze_WhenTableWasFrozenAlready_ReturnsFalse()
        {
            using (var scenario = MultiLevelTableScenario.Setup())
            {
                // Arrange
                scenario.Table.Freeze();

                // Act
                var r = scenario.Table.Freeze();

                // Assert
                r.Should().Be(false);
            }
        }
        public void TransformToSourceTable_ProducesCorrectTable()
        {
            using (var scenario = MultiLevelTableScenario.Setup())
            {
                // Act
                var src         = new FileConfigStore(TomlSettings.DefaultInstance, "test", "test");
                var sourceTable = scenario.Table.TransformToSourceTable(src);

                // Assert
                sourceTable.Get <IConfigSource>(nameof(scenario.Clr.X)).Should().BeSameAs(src);
                var sub = sourceTable.Get <TomlTable>(nameof(scenario.Clr.Sub));
                sub.Get <IConfigSource>(nameof(scenario.Clr.Sub.Y)).Should().BeSameAs(src);
            }
        }
示例#6
0
        public void TransformToSourceTable_ProducesCorrectTable()
        {
            using (var scenario = MultiLevelTableScenario.Setup())
            {
                // Act
                var src         = new ConfigSource("test");
                var sourceTable = scenario.Table.TransformToSourceTable(new ConfigSource("test"));

                // Assert
                sourceTable.Get <IConfigSource>(nameof(scenario.Clr.X)).Should().Be(src);
                var sub = sourceTable.Get <TomlTable>(nameof(scenario.Clr.Sub));
                sub.Get <IConfigSource>(nameof(scenario.Clr.Sub.Y)).Should().Be(src);
            }
        }