예제 #1
0
 public void GetInstanceMissingTest()
 {
     using (var db = new ASP_DBEntities())
         using (var trans = db.Database.BeginTransaction(IsolationLevel.ReadUncommitted))
         {
             var none = db.LoadMain(Guid.NewGuid());
             Assert.That(none, Is.Null);
         }
 }
예제 #2
0
        public void VerifyFibonacciSums()
        {
            CalculatorController inst;

            using (var db = new ASP_DBEntities())
            {
                var bytes = db.LoadMain(this.config.GetValue <Guid>("asp.Controllers.FibonacciTest"));
                inst = new CalculatorController();
                inst.Deserialize(bytes);
                inst.Fsm.Owner = inst;                                 // As in ISmcControl.LoadMain<M, F, S>(), see SMC Manual Section 9
            }
            Assert.That(inst.Stack.Count, Is.GreaterThanOrEqualTo(3)); // non-empty sequence
            Assert.That(inst.State, Is.EqualTo(CalculatorContext.Map1.Calculate));

            // Assert the sums backwards on the model objects instead of the GUI
            while (inst.Stack.Count >= 3)
            {
                var initialStackCount = inst.Stack.Count;

                // Get the head of the sequence to check
                var sum      = inst.Stack.ElementAt(0);
                var summand1 = inst.Stack.ElementAt(1);
                var summand2 = inst.Stack.ElementAt(2);

                // Check the correctness of the Fibonacci sequence  in the calculator GUI

                // Delete the current sum and recalculate it from the sequence
                inst.Fsm.Clr(inst.Stack);       // this.Click("calculate.clrButton");
                inst.Fsm.Add(inst.Stack);       //this.Click("calculate.addButton");
                Assert.That(inst.Stack.ElementAt(0), Is.EqualTo(sum));

                // Delete the calculated check sum
                inst.Fsm.Clr(inst.Stack);       // this.Click("calculate.clrButton");

                // Put the original summands onto the stack again
                inst.Fsm.Enter("");             // this.Click("footer.enterButton");
                inst.Fsm.Enter(summand2);       // this.Write("enter.operandTextBox", summand2);
                                                // this.Click("footer.enterButton");

                inst.Fsm.Enter("");             // this.Click("footer.enterButton");
                inst.Fsm.Enter(summand1);       // this.Write("enter.operandTextBox", summand1);
                                                // this.Click("footer.enterButton");

                // Check that the loop will terminate by continuing with N-1 elements
                Assert.That(inst.Stack.Count, Is.EqualTo(initialStackCount - 1));
            }
        }
예제 #3
0
        public void LoadSaveMainTest()
        {
            var bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7 };

            using (var db = new ASP_DBEntities())
                using (var trans = db.Database.BeginTransaction())
                {
                    try
                    {
                        // Local SetUp
                        var session = db.SaveMain(typeof(TestClass), bytes, null);

                        // Method under test
                        var copy = db.LoadMain(session);
                        Assert.That(copy, Is.EquivalentTo(bytes));
                    }
                    finally
                    {
                        trans.Rollback();
                    }
                }
        }
예제 #4
0
        public void TestReadInexistent(ASP_DBEntities db, Guid session)
        {
            var read = db.LoadMain(session);

            Assert.That(read, Is.Null);
        }