Ejemplo n.º 1
0
        public void CreateUser()
        {
            var userRepository = new MockUserRepository();
            var userWorkflow   = new UserWorkflow(userRepository);

            userWorkflow.CreateUser("easy", "crud");
            userRepository.CalledCreateUser.Should().BeTrue();
            userRepository.User.Username.Should().Be("easy");
        }
Ejemplo n.º 2
0
        public void ExistingUserShouldThrowException()
        {
            var userRepository = new MockUserRepository();
            var userWorkflow   = new UserWorkflow(userRepository);

            Action action = () => userWorkflow.CreateUser("existing_user", "anyPassword");

            action.Should().Throw <UserAlreadyExistException>("User already exists");
        }
Ejemplo n.º 3
0
 private async Task UpdateDbWorkflow(UserWorkflow userWorkflow)
 {
     foreach (var step in userWorkflow.Steps)
     {
         if (step.TrackingState == TrackingState.Updated)
         {
             _db.Entry(step).State = EntityState.Modified;
         }
     }
     _db.Entry(userWorkflow).State = EntityState.Modified;
     await _db.SaveChangesAsync();
 }
Ejemplo n.º 4
0
        public async Task InsertTestData(AppDbContext db)
        {
            var userWorkflow = new UserWorkflow(
                SupportedWorkflows.OnBoarding.ToString(),
                "*****@*****.**",
                "test1",
                10,
                new DateTime(2018, 12, 20)
                );

            var personalStep = new UserWorkflowStep(Steps.Personal.ToString());

            personalStep.MarkIsStepComplete(true);
            userWorkflow.AddWorkflowStep(personalStep);

            var workStep = new UserWorkflowStep(Steps.Work.ToString());

            workStep.MarkIsStepComplete(true);
            userWorkflow.AddWorkflowStep(workStep);

            var addressStep = new UserWorkflowStep(Steps.Address.ToString());

            addressStep.MarkIsStepComplete(true);
            userWorkflow.AddWorkflowStep(addressStep);

            var resultStep = new UserWorkflowStep(Steps.Result.ToString());

            resultStep.MarkIsStepComplete(true);
            userWorkflow.AddWorkflowStep(resultStep);


            userWorkflow.SetPersonal("Jawad", "Hasan", "*****@*****.**");
            userWorkflow.SetWork("Code");
            userWorkflow.SetAddress("Willy-Brandt-Plataz", "Braunschweig", "38114", "SomeState");
            userWorkflow.UpdateStatus(WorkflowStatus.Completed);

            db.UserWorkflows.Add(userWorkflow);

            foreach (var step in userWorkflow.Steps)
            {
                if (step.TrackingState == TrackingState.Created)
                {
                    db.Entry(step).State = EntityState.Added;
                }
            }
            await db.SaveChangesAsync();

            //_workflowDataService.SaveWorkflowAsync(dbWorkflow);
        }
Ejemplo n.º 5
0
        private void UpdateWorkflow(BaseWorkflow workflow, UserWorkflow existingUserWorkflow)
        {
            //not updating the primary properties e.g. sourceEmailAddress, expiresIn etc.
            existingUserWorkflow.SetPersonal(workflow.WorkflowData.FirstName, workflow.WorkflowData.LastName, workflow.WorkflowData.Email);
            existingUserWorkflow.SetWork(workflow.WorkflowData.Work);
            existingUserWorkflow.SetAddress(workflow.WorkflowData.Street, workflow.WorkflowData.City, workflow.WorkflowData.Zip, workflow.WorkflowData.State);
            existingUserWorkflow.UpdateStatus(workflow.Status);

            foreach (var step in existingUserWorkflow.Steps)
            {
                if (step.TrackingState == TrackingState.Updated)
                {
                    _db.Entry(step).State = EntityState.Modified;
                }
            }

            _db.Entry(existingUserWorkflow).State = EntityState.Modified;
            _db.SaveChanges();
        }
Ejemplo n.º 6
0
        //TODO: SRP
        private async Task SaveNewUserWorkflow(BaseWorkflow workflow)
        {
            //Building
            var dbWorkflow = new UserWorkflow(workflow.Name, workflow.SourceEmailAddress, workflow.RequestId, workflow.ExpiresIn, workflow.CreatedOn);

            foreach (var step in workflow.Steps)
            {
                dbWorkflow.AddWorkflowStep(new UserWorkflowStep(step.Step));
            }

            //Persisting
            foreach (var step in dbWorkflow.Steps)
            {
                if (step.TrackingState == TrackingState.Created)
                {
                    _db.Entry(step).State = EntityState.Added;
                }
            }
            _db.UserWorkflows.Add(dbWorkflow);
            await _db.SaveChangesAsync();
        }
 public void Cleanup()
 {
     Browser.Close();
     _browser      = null;
     _userWorkFlow = null;
 }
Ejemplo n.º 8
0
 public ApplicationWorkflow(UserWorkflow dataUserWorkflow)
 {
     _dataUserWorkflow = dataUserWorkflow;
 }