public async Task FollowUp_WithControlValues_CheckControlsValuesRetained() { //Arrage _sendEmailActivity = New <Send_Email_v1>(); var activityContext = new ActivityContext { HubCommunicator = ObjectFactory.GetInstance <IHubCommunicator>(), ActivityPayload = new ActivityPayload { CrateStorage = new CrateStorage() } }; await _sendEmailActivity.Configure(activityContext); var storage = activityContext.ActivityPayload.CrateStorage; var controls = storage.CratesOfType <StandardConfigurationControlsCM>().Single(); var emailAddressControl = controls.Content.Controls.OfType <TextSource>().Single(t => t.Name.Equals("EmailAddress")); emailAddressControl.TextValue = "*****@*****.**"; //Act await _sendEmailActivity.Configure(activityContext); //Assert var configControls = storage.CratesOfType <StandardConfigurationControlsCM>().Single(); var emailAddressCtl = configControls.Content.Controls.OfType <TextSource>().Single(c => c.Name.Equals("EmailAddress")); Assert.IsNotNull(emailAddressCtl, "Email Address field is missing in Send Email activity"); Assert.AreEqual("*****@*****.**", emailAddressCtl.TextValue, "Text value is not retained in Send Email activity configuration"); }
public async Task Run_CheckSendCalledOnlyOnce() { //Arrage _sendEmailActivity = New <Send_Email_v1>(); var activityContext = new ActivityContext { HubCommunicator = ObjectFactory.GetInstance <IHubCommunicator>(), ActivityPayload = new ActivityPayload { CrateStorage = new CrateStorage() }, AuthorizationToken = new AuthorizationToken { Token = "1" } }; var executionContext = new ContainerExecutionContext { PayloadStorage = new CrateStorage(Crate.FromContent(string.Empty, new OperationalStateCM())) }; await _sendEmailActivity.Configure(activityContext); var storage = activityContext.ActivityPayload.CrateStorage; var controls = storage.CratesOfType <StandardConfigurationControlsCM>().Single(); var emailAddressControl = controls.Content.Controls.OfType <TextSource>().Single(t => t.Name.Equals("EmailAddress")); emailAddressControl.TextValue = "*****@*****.**"; var subjectControl = controls.Content.Controls.OfType <TextSource>().Single(t => t.Name.Equals("EmailSubject")); subjectControl.TextValue = "some subject"; var bodyControl = controls.Content.Controls.OfType <TextSource>().Single(t => t.Name.Equals("EmailBody")); bodyControl.TextValue = "some body"; subjectControl.ValueSource = bodyControl.ValueSource = emailAddressControl.ValueSource = "specific"; //Act await _sendEmailActivity.Run(activityContext, executionContext); //Assert var emailPackagerMock = Mock.Get(ObjectFactory.GetInstance <IEmailPackager>()); emailPackagerMock.Verify(p => p.Send(It.IsAny <TerminalMailerDO>()), Times.Once()); }
public async Task Initialize_CheckConfigControls() { //Arrage _sendEmailActivity = New <Send_Email_v1>(); //Act var activityContext = new ActivityContext { HubCommunicator = ObjectFactory.GetInstance <IHubCommunicator>(), ActivityPayload = new ActivityPayload { CrateStorage = new CrateStorage() } }; await _sendEmailActivity.Configure(activityContext); //Assert var configControls = activityContext.ActivityPayload.CrateStorage.CratesOfType <StandardConfigurationControlsCM>().Single(); Assert.IsNotNull(configControls, "Send Email is not initialized properly."); Assert.IsTrue(configControls.Content.Controls.Count == 3, "Send Email configuration controls are not created correctly."); }