Beispiel #1
0
        public R1Employee CreateTestEmployee(LubrizolData context, string firstName, string middleName, string lastName, string employeeId, string status = "Active")
        {
            var employee = context.Lubrizol_Employees.FirstOrDefault(x => x.EmployeeID == employeeId);

            if (employee != null)
            {
                DeleteTestEmployee(context, employeeId);
            }

            employee = new R1Employee
            {
                FirstName  = firstName,
                MiddleName = middleName,
                LastName   = lastName,
                EmployeeID = employeeId,
                Name       = string.Format("{0} {1}", firstName, lastName),
                Initials   = string.Format("{0}{1}{2}", string.IsNullOrWhiteSpace(firstName) ? "" : firstName.Substring(0, 1)
                                           , string.IsNullOrWhiteSpace(middleName) ? "" : middleName.Substring(0, 1)
                                           , string.IsNullOrWhiteSpace(lastName) ? "" : lastName.Substring(0, 1)),
                LastLoadDate       = DateTime.Now,
                LastUpdated        = DateTime.Now,
                EmployeeStatus     = status == "Active" ? 'A' : 'I',
                EmployeeStatusDesc = status,
                Division           = Guid.NewGuid().ToString()
            };

            context.Lubrizol_Employees.InsertOnSubmit(employee);
            context.SubmitChanges();

            return(employee);
        }
Beispiel #2
0
        public override void Cleanup()
        {
            using (var context = new LubrizolData())
            {
                context.Lubrizol_Employees.DeleteAllOnSubmit(context.Lubrizol_Employees);
                context.SubmitChanges(ConflictMode.FailOnFirstConflict);
            }

            base.Cleanup();
        }
Beispiel #3
0
        private void CallLubrizolExport_Click(object sender, EventArgs e)
        {
            const string taskName  = "LubrizolExport";
            const string employee1 = "TEST_1";
            const string employee2 = "TEST_2";

            Configuration.SaveConfigValue("ServiceId", "6");
            Configuration.SaveConfigValue("ServiceName", "R1SM.LubrizolExport");
            Configuration.SaveConfigValue("Description", "Performs export operations for R1SM's SharePoint integration.");
            Configuration.SaveConfigValue("Task1", "LubrizolExport");

            var result = Result <string> .Success();

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                CreateTestPerson(context, StageData.People.R1Person1.FirstName, StageData.People.R1Person1.MiddleName, StageData.People.R1Person1.LastName, employee1, S2In, RSM.Service.Library.Tests.Properties.Resources.BadPiggies);
                CreateTestPerson(context, StageData.People.R1Person2.FirstName, StageData.People.R1Person2.MiddleName, StageData.People.R1Person2.LastName, employee2, S2In, RSM.Service.Library.Tests.Properties.Resources.AngryBirdsRed);
            }

            using (var context = new LubrizolData())
            {
                CreateTestEmployee(context, StageData.People.R1Person1.FirstName, StageData.People.R1Person1.MiddleName, StageData.People.R1Person1.LastName, employee1, "Active");
                CreateTestEmployee(context, StageData.People.R1Person2.FirstName, StageData.People.R1Person2.MiddleName, StageData.People.R1Person2.LastName, employee2, "Inactive");
            }

            try
            {
                var task = Task.Create(taskName, new ServiceProfile());

                var import = task as RSM.Integration.Lubrizol.Export.People;

                result = import.Execute(null);

                txtOutput.Text += Environment.NewLine + string.Format(result.Message);
            }
            catch (Exception ex)
            {
                txtOutput.Text += Environment.NewLine + string.Format("Test exception! {0}", ex.ToString());
            }

            // Clean out test data
            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                DeleteTestPerson(context, employee1, S2In);
                DeleteTestPerson(context, employee2, S2In);
            }

            using (var context = new LubrizolData())
            {
                DeleteTestEmployee(context, employee1);
                DeleteTestEmployee(context, employee2);
            }
        }
Beispiel #4
0
        public void DeleteTestEmployee(LubrizolData context, string employeeId)
        {
            var employee = context.Lubrizol_Employees.FirstOrDefault(x => x.EmployeeID == employeeId);

            if (employee == null)
            {
                txtOutput.Text += Environment.NewLine + string.Format("ERROR: Employee ({0}) Not Found in Employees.", employeeId);
                return;
            }

            context.Lubrizol_Employees.DeleteOnSubmit(employee);
            context.SubmitChanges();
        }
        public void Execute_NoStub()
        {
            const string taskName  = "LubrizolExport";
            const string employee1 = "_1";
            const string employee2 = "_2";

            var result = Result <string> .Success();

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                LoadLubrizolImportTestData(context, taskName);

                CreateTestPerson(context, StageData.People.R1Person1.FirstName, StageData.People.R1Person1.MiddleName, StageData.People.R1Person1.LastName, employee1, S2In, Properties.Resources.BadPiggies);
                CreateTestPerson(context, StageData.People.R1Person2.FirstName, StageData.People.R1Person2.MiddleName, StageData.People.R1Person2.LastName, employee2, S2In, Properties.Resources.AngryBirdsRed);
            }

            using (var context = new LubrizolData())
            {
                CreateTestEmployee(context, StageData.People.R1Person1.FirstName, StageData.People.R1Person1.MiddleName, StageData.People.R1Person1.LastName, employee1);
                CreateTestEmployee(context, StageData.People.R1Person2.FirstName, StageData.People.R1Person2.MiddleName, StageData.People.R1Person2.LastName, employee2);
            }

            try
            {
                var task = Task.Create(taskName, new ServiceProfile());

                var import = task as Integration.Lubrizol.Export.People;

                result = import.Execute(null);
            }
            catch (Exception e)
            {
                Assert.Fail("Test exception! {0}", e.ToString());
            }

            Assert.IsNotNull(result, "Missing results");
            Assert.IsTrue(result.Succeeded, result.ToString());
        }
Beispiel #6
0
        public void LubrizolEmployeeImportUpdate_Execute_NoStub()
        {
            const string taskName  = "LubrizolImport";
            const string employee1 = "_1";
            const string employee2 = "_2";

            var result = Result <string> .Success();

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                //Load settings.
                //Includes a field level filter on
                LoadLubrizolImportTestData(context, taskName);

                CreateTestPerson(context, StageData.People.R1Person1.FirstName, StageData.People.R1Person1.MiddleName, StageData.People.R1Person1.LastName, employee1, S2In);
                CreateTestPerson(context, StageData.People.R1Person2.FirstName, StageData.People.R1Person2.MiddleName, StageData.People.R1Person2.LastName, employee2, S2In);
            }

            try
            {
                var task = Task.Create(taskName, new ServiceProfile());

                var import = task as Integration.Lubrizol.Employees;

                result = import.Execute(null);
            }
            catch (Exception e)
            {
                Assert.Fail("Test exception! {0}", e.ToString());
            }

            Assert.IsNotNull(result, "Missing results");
            Assert.IsTrue(result.Succeeded, result.ToString());

            DateTime empl1Date;
            DateTime empl2Date;

            using (var context = new LubrizolData())
            {
                empl1Date = context.Lubrizol_Employees.First(x => x.EmployeeID == employee1).LastUpdated;
                empl2Date = context.Lubrizol_Employees.First(x => x.EmployeeID == employee2).LastUpdated;

                var employee = context.Lubrizol_Employees.First(x => x.EmployeeID == employee1);
                employee.Division = Guid.NewGuid().ToString();

                context.SubmitChanges();
            }

            Thread.SpinWait(100);

            try
            {
                var task = Task.Create(taskName, new ServiceProfile());

                var import = task as Integration.Lubrizol.Employees;

                result = import.Execute(null);
            }
            catch (Exception e)
            {
                Assert.Fail("Test exception! {0}", e.ToString());
            }

            Assert.IsNotNull(result, "Missing results");
            Assert.IsTrue(result.Succeeded, result.ToString());

            using (var context = new LubrizolData())
            {
                Assert.AreNotEqual(context.Lubrizol_Employees.First(x => x.EmployeeID == employee1).LastUpdated, empl1Date, "Update date not changed");
                Assert.AreEqual(context.Lubrizol_Employees.First(x => x.EmployeeID == employee2).LastUpdated, empl2Date, "Update date changed");
            }

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                var internalKey = context.ExternalApplicationKeys.First(x => x.EntityType == "Person" && x.ExternalId == employee1).InternalId;
                var person      = context.Persons.First(x => x.PersonID == internalKey);
                Assert.AreNotEqual(person.LastUpdated, empl1Date, "Update date not changed");

                internalKey = context.ExternalApplicationKeys.First(x => x.EntityType == "Person" && x.ExternalId == employee2).InternalId;
                person      = context.Persons.First(x => x.PersonID == internalKey);
                Assert.AreEqual(person.LastUpdated, empl2Date, "Update date changed");
            }
        }