示例#1
0
        public void Create_Returns_CorrectParameterData()
        {
            var panelController = new PanelController();

            var key = new Key
            {
                Description = "TestDescription1",
                Name        = "TestName1",
                Illuminated = true,
                State       = KeyState.In,
                PersonID    = 0
            };

            panelController.Create(null, key);

            Key      returnKey;
            KeyAudit returnKeyAudit;

            using (var context = new KeyContext())
            {
                returnKey      = context.Keys.FirstOrDefault(r => r.Name.Equals("TestName1"));
                returnKeyAudit = context.KeyAudits.FirstOrDefault(r => r.Name.Equals("TestName1"));
            }

            Assert.That(returnKey != null, "No object returned");

            keys.Add(returnKey.ID);

            bool valuesMatch = key.Description == returnKey.Description;

            Assert.IsTrue(valuesMatch, "Description of return object did not match persisted object");

            valuesMatch = key.Illuminated == returnKey.Illuminated;
            Assert.IsTrue(valuesMatch, "Illuminated of return object did not match persisted object");

            valuesMatch = key.PersonID == returnKey.PersonID;
            Assert.IsTrue(valuesMatch, "PersonID of return object did not match persisted object");

            valuesMatch = key.State == returnKey.State;
            Assert.IsTrue(valuesMatch, "State of return object did not match persisted object");

            Assert.That(returnKeyAudit != null, "No audit object returned");

            valuesMatch = returnKeyAudit.AuditNote.Equals("INSERT");
            Assert.IsTrue(valuesMatch, "No audit note was attached to audit record");

            valuesMatch = key.Description == returnKeyAudit.Description;
            Assert.IsTrue(valuesMatch, "Description of return audit object did not match object");

            valuesMatch = key.Illuminated == returnKeyAudit.Illuminated;
            Assert.IsTrue(valuesMatch, "Illuminated of return audit object did not match object");

            valuesMatch = key.PersonID == returnKeyAudit.PersonID;
            Assert.IsTrue(valuesMatch, "PersonID of return audit object did not match object");

            valuesMatch = key.State == returnKeyAudit.State;
            Assert.IsTrue(valuesMatch, "State of return audit object did not match  object");
        }