Пример #1
0
        public void DeleteStaffTest()
        {
            MasterDataLinqBroker target = new MasterDataLinqBroker(); // TODO: Initialize to an appropriate value
            IStaff staff = target.GetStaffById(4); // TODO: Initialize to an appropriate value
            string deletedBy = "Test case"; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.DeleteStaff(staff, deletedBy);
            Assert.AreEqual(expected, actual);

            target = new MasterDataLinqBroker();
            //IStaff updated = target.GetStaffById(4);
            IStaff updated = Context.Staffs.SingleOrDefault(s => s.StaffID == 4);

            Assert.AreEqual(actual, updated.IsDeleted);
            Assert.AreEqual(actual, true);
            Assert.AreEqual(updated.IsDeleted, true);
            //Assert.AreEqual(staff.DeletedBy, "Test case");
            //Assert.AreEqual(updated.DeletedBy, "Test case");

            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
Пример #2
0
        public void GetStaffByIdTest()
        {
            MasterDataLinqBroker target = new MasterDataLinqBroker(); // TODO: Initialize to an appropriate value
            int staffId = 5; // TODO: Initialize to an appropriate value
            IStaff expected = Context.Staffs.SingleOrDefault(s => s.StaffID == 5); // TODO: Initialize to an appropriate value
            IStaff actual;
            actual = target.GetStaffById(staffId);
            //Assert.AreEqual(expected, actual);

            Assert.AreEqual(expected.StaffID, actual.StaffID);
            Assert.AreEqual(expected.InitialName, actual.InitialName);
            Assert.AreEqual(expected.FirstName, actual.FirstName);
            Assert.AreEqual(expected.LastName, actual.LastName);
            Assert.AreEqual(expected.DateofBirth, actual.DateofBirth);
            Assert.AreEqual(expected.Gender, actual.Gender);
            Assert.AreEqual(expected.PostCode, actual.PostCode);
            Assert.AreEqual(expected.Address, actual.Address);
            Assert.AreEqual(expected.Province, actual.Province);
            Assert.AreEqual(expected.PhoneNo, actual.PhoneNo);
            Assert.AreEqual(expected.IsDeleted, actual.IsDeleted);
            Assert.AreEqual(expected.UserGuid, actual.UserGuid);

            Assert.AreEqual(expected.RowGuid, actual.RowGuid);

            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
Пример #3
0
        public void GetStaffListTest1()
        {
            MasterDataLinqBroker target = new MasterDataLinqBroker(); // TODO: Initialize to an appropriate value
            List<IStaff> expected = Context.Staffs.Where(s => !s.IsDeleted).Cast<IStaff>().ToList();
            IList<IStaff> actual;
            actual = target.GetStaffList();

            IEnumerator<IStaff> e1 = expected.GetEnumerator();
            IEnumerator<IStaff> e2 = actual.GetEnumerator();

            while (e1.MoveNext() && e2.MoveNext())
            {
                Assert.AreEqual(e1.Current.StaffID, e2.Current.StaffID);
                Assert.AreEqual(e1.Current.InitialName, e2.Current.InitialName);
                Assert.AreEqual(e1.Current.FirstName, e2.Current.FirstName);
                Assert.AreEqual(e1.Current.LastName, e2.Current.LastName);
                Assert.AreEqual(e1.Current.DateofBirth, e2.Current.DateofBirth);
                Assert.AreEqual(e1.Current.Gender, e2.Current.Gender);
                Assert.AreEqual(e1.Current.PostCode, e2.Current.PostCode);
                Assert.AreEqual(e1.Current.Address, e2.Current.Address);
                Assert.AreEqual(e1.Current.Province, e2.Current.Province);
                Assert.AreEqual(e1.Current.PhoneNo, e2.Current.PhoneNo);
                Assert.AreEqual(e1.Current.IsDeleted, e2.Current.IsDeleted);
                Assert.AreEqual(e1.Current.UserGuid, e2.Current.UserGuid);

                Assert.AreEqual(e1.Current.RowGuid, e2.Current.RowGuid);

            }

            //Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
Пример #4
0
        public void SaveStaffTest()
        {
            MasterDataLinqBroker target = new MasterDataLinqBroker(); // TODO: Initialize to an appropriate value
            IStaff staff = target.GetStaffById(5); // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;

            int phone = new Random().Next(23421, 999999);
            staff.PhoneNo = phone.ToString();

            actual = target.SaveStaff(staff, "unit test");
            Assert.AreEqual(expected, actual);

            target = new MasterDataLinqBroker();
            IStaff updated = target.GetStaffById(5);

            Assert.AreEqual(updated.PhoneNo, staff.PhoneNo);
            Assert.AreEqual(updated.PhoneNo, phone.ToString());
            Assert.AreEqual(staff.PhoneNo, phone.ToString());
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
Пример #5
0
        public void GetStaffListTest()
        {
            MasterDataLinqBroker target = new MasterDataLinqBroker(); // TODO: Initialize to an appropriate value
            string sortExp = string.Empty; // TODO: Initialize to an appropriate value
            bool sortDesc = false; // TODO: Initialize to an appropriate value
            int startIndex = 0; // TODO: Initialize to an appropriate value
            int pageSize = 1110; // TODO: Initialize to an appropriate value
            string filter = "City.Contains(\"renon\")"; // TODO: Initialize to an appropriate value
            char gender = 'P';
            IList<IStaff> expected = Context.Staffs.Where(p => p.StaffID == 6).Cast<IStaff>().ToList(); // TODO: Initialize to an appropriate value
            IList<IStaff> actual;
            actual = target.GetStaffList(gender, sortExp, sortDesc, startIndex, pageSize, filter);

            IEnumerator<IStaff> e1 = expected.GetEnumerator();
            IEnumerator<IStaff> e2 = actual.GetEnumerator();

            while (e1.MoveNext() && e2.MoveNext())
            {
                Assert.AreEqual(e1.Current.StaffID, e2.Current.StaffID);
                Assert.AreEqual(e1.Current.InitialName, e2.Current.InitialName);
                Assert.AreEqual(e1.Current.FirstName, e2.Current.FirstName);
                Assert.AreEqual(e1.Current.LastName, e2.Current.LastName);
                Assert.AreEqual(e1.Current.DateofBirth, e2.Current.DateofBirth);
                Assert.AreEqual(e1.Current.Gender, e2.Current.Gender);
                Assert.AreEqual(e1.Current.PostCode, e2.Current.PostCode);
                Assert.AreEqual(e1.Current.Address, e2.Current.Address);
                Assert.AreEqual(e1.Current.Province, e2.Current.Province);
                Assert.AreEqual(e1.Current.PhoneNo, e2.Current.PhoneNo);
                Assert.AreEqual(e1.Current.IsDeleted, e2.Current.IsDeleted);
                Assert.AreEqual(e1.Current.UserGuid, e2.Current.UserGuid);

                Assert.AreEqual(e1.Current.RowGuid, e2.Current.RowGuid);

            }

            //Assert.Inconclusive("Verify the correctness of this test method.");
        }