Exemple #1
0
        public void addUserFindUserDeleteUserToDatabaseTest()
        {
            andy680Entities db = new andy680Entities();

            User user = new User();

            //user.UserId = 1; - this is auto-assigned by db
            user.UserName       = "******";
            user.Password       = "******";
            user.OrganizationId = 1;
            user.FirstName      = "Test";
            user.LastName       = "User";
            user.AdminFlag      = false;
            user.ActiveDate     = System.DateTime.Now;

            //add user to database
            db.Users.Add(user);
            db.SaveChanges();
            Assert.IsTrue(user.validate());

            //find user
            User user2 = db.Users.Find(user.UserId);
            int  id    = user2.UserId;

            System.Diagnostics.Debug.WriteLine("The user's id is {0}", id);
            Assert.IsTrue(user2.Equals(user));

            //remove user
            db.Users.Remove(user);
            db.SaveChanges();
        }
        public void addMessageFindMessageDeleteMessageDatabaseTest()
        {
            //get database connection
            andy680Entities db = new andy680Entities();

            Message message = new Message();

            //message.MessageId = 1;  - this is auto-assigned by db
            message.CorrelationIdentifier = 1010101;
            message.SendingOrgId          = 1;
            message.ReceivingOrgId        = 1;
            message.Severity   = 3;
            message.OrgMessage = "This is a test message";
            message.Timestamp  = System.DateTime.Now;

            //add message to database
            db.Messages.Add(message);
            db.SaveChanges();
            Assert.IsTrue(message.validate());

            //find message
            Message message2 = db.Messages.Find(message.MessageId);
            int     id       = message2.MessageId;

            System.Diagnostics.Debug.WriteLine("The messages's id is {0}", id);
            Assert.IsTrue(message2.Equals(message));

            //clean up by removing message
            db.Messages.Remove(message);
            db.SaveChanges();
        }
Exemple #3
0
        public void addOrganizationFindOrganizationDeleteOrganizationDatabaseTest()
        {
            //get database connection
            andy680Entities db = new andy680Entities();

            Organization organization = new Organization();

            //organization.OrganizationId = 1;  - this is auto-assigned in db
            organization.Name      = "testorg";
            organization.Street    = "Testing St";
            organization.City      = "Anytown";
            organization.State     = "CO";
            organization.Zip       = "80000";
            organization.StartDate = System.DateTime.Now;

            //add org to database
            db.Organizations.Add(organization);
            db.SaveChanges();
            Assert.IsTrue(organization.validate());

            //find organization
            Organization organization2 = db.Organizations.Find(organization.OrganizationId);
            int          id            = organization2.OrganizationId;

            System.Diagnostics.Debug.WriteLine("The organization's id is {0}", id);
            Assert.IsTrue(organization2.Equals(organization));

            //clean up by removing organization
            db.Organizations.Remove(organization);
            db.SaveChanges();
        }