示例#1
0
        public void Exceptions()
        {
            Calculator_ calc = new Calculator_(new CalculatorProps
            {
                InitialValue = 20,
                MaximumValue = 30,
            });

            calc.Add(3);
            Assert.Equal((double)23, calc.Value);

            Assert.Throws <JsiiException>(() => calc.Add(10));

            calc.MaxValue = 40;
            calc.Add(10);
            Assert.Equal((double)33, calc.Value);
        }
示例#2
0
        public void Maps()
        {
            // TODO: Generator should create a parameterless constructor.
            Calculator_ calc = new Calculator_(new CalculatorProps());

            calc.Add(10);
            calc.Add(20);
            calc.Mul(2);
            Assert.Collection(
                calc.OperationsMap["add"],
                val => { },
                val => Assert.Equal((double)30, val.Value)
                );
            Assert.Collection(
                calc.OperationsMap["mul"],
                val => { }
                );
        }
示例#3
0
        public void GetAndSetNotPrimitiveProperties()
        {
            // TODO: Generator should create a parameterless constructor.
            Calculator_ calc = new Calculator_(new CalculatorProps());

            calc.Add(3200000);
            calc.Neg();
            calc.Curr = new Multiply(new Number(2), calc.Curr);
            Assert.Equal((double)-6400000, calc.Value);
        }
示例#4
0
        public void UnmarkshallIntoAbstractType()
        {
            // TODO: Generator should create a parameterless constructor.
            Calculator_ calc = new Calculator_(new CalculatorProps());

            calc.Add(120);
            Value_ value = calc.Curr;

            Assert.Equal((double)120, value.Value);
        }
示例#5
0
        public void FluentApi()
        {
            Calculator_ calc = new Calculator_(new CalculatorProps
            {
                InitialValue = 20,
                MaximumValue = 30,
            });

            calc.Add(3);
            Assert.Equal(23, calc.Value);
        }
示例#6
0
        public void GetAndSetEnumValues()
        {
            // TODO: Generator should create a parameterless constructor.
            Calculator_ calc = new Calculator_(new CalculatorProps());

            calc.Add(9);
            calc.Pow(3);
            Assert.Equal(CompositionStringStyle.Normal, calc.StringStyle);
            calc.StringStyle = CompositionStringStyle.Decorated;
            Assert.Equal(CompositionStringStyle.Decorated, calc.StringStyle);
            Assert.Equal("<<[[{{(((1 * (0 + 9)) * (0 + 9)) * (0 + 9))}}]]>>", calc.ToString());
        }
示例#7
0
        public void CallMethods()
        {
            // TODO: Generator should create a parameterless constructor.
            Calculator_ calc = new Calculator_(new CalculatorProps());

            calc.Add(10);
            Assert.Equal((double)10, calc.Value);

            calc.Mul(2);
            Assert.Equal((double)20, calc.Value);

            calc.Pow(5);
            Assert.Equal((double)20 * 20 * 20 * 20 * 20, calc.Value);

            calc.Neg();
            Assert.Equal((double)-3200000, calc.Value);
        }