Exemple #1
0
        public void GetAllVars()
        {
            // Arrange
            var context = new TestCaseContext();
            var sut     = new VarsManager(
                context.OptionsService,
                context.Logger);

            var random = new Random();

            int varsCount = 5;
            var vars      = new List <IVar>();

            for (int i = 0; i < varsCount; ++i)
            {
                vars.Add(new IntVar(
                             $"key{i}",
                             $"var-name{i}",
                             random.Next(-100, 100)));
            }

            // Act
            foreach (var v in vars)
            {
                sut.AddVar(v);
            }
            var actual = sut.GetAllVars();

            // Assert
            Assert.Equal(vars, actual);
        }
Exemple #2
0
        public void Init()
        {
            // Arrange
            var context = new TestCaseContext();
            var sut     = new VarsManager(
                context.OptionsService,
                context.Logger);

            var userName = "******";
            var vars     = new List <IVar>
            {
                new IntVar("v1", "v1-name", 0),
                new IntVar("v2", "v2-name", 1),
                new IntVar("v3", "v3-name", 2),
            };

            // Act
            sut.Init(userName, vars);
            var allVars     = sut.GetAllVars();
            var userNameVar = sut.GetVar <StringVar>(context.Options.UserNameVarKey);

            // Assert
            Assert.Equal(vars.Count + 1, allVars.Count());
            Assert.Equal(userName, userNameVar.Value);
        }
Exemple #3
0
        public void ClearVars()
        {
            // Arrange
            var context = new TestCaseContext();
            var sut     = new VarsManager(
                context.OptionsService,
                context.Logger);

            int varsCount = 3;

            var vars = new List <IntVar>();

            for (int i = 0; i < varsCount; ++i)
            {
                sut.AddVar(new IntVar($"key{i}", $"var-name{i}"));
            }

            // Act
            sut.ClearVars();

            // Assert
            Assert.Empty(sut.GetAllVars());
        }