public async Task Run_CheckSendCalledOnlyOnce() { //Arrage _sendSmsActivity = New <Send_SMS_v1>(); var activityContext = new ActivityContext { HubCommunicator = ObjectFactory.GetInstance <IHubCommunicator>(), ActivityPayload = new ActivityPayload { CrateStorage = new CrateStorage() }, AuthorizationToken = new AuthorizationToken { Token = "1" } }; var containerExecutionContext = new ContainerExecutionContext { PayloadStorage = new CrateStorage(Crate.FromContent(string.Empty, new OperationalStateCM())) }; await _sendSmsActivity.Configure(activityContext); var controls = activityContext.ActivityPayload.CrateStorage.CratesOfType <StandardConfigurationControlsCM>().Single(); var smsNumber = controls.Content.Controls.OfType <TextSource>().Single(t => t.Name.Equals("SmsNumber")); smsNumber.TextValue = "+918055967968"; //This is some dummy number. This number is not valid var smsBody = controls.Content.Controls.OfType <TextSource>().Single(t => t.Name.Equals("SmsBody")); smsBody.TextValue = "some body"; smsBody.ValueSource = smsNumber.ValueSource = "specific"; //Act await _sendSmsActivity.Run(activityContext, containerExecutionContext); //Assert var messageDataCrate = containerExecutionContext.PayloadStorage.CratesOfType <StandardPayloadDataCM>().Single(p => p.Label.Equals("Message Data")); Assert.IsNotNull(messageDataCrate, "Send SMS activity is not run."); Assert.AreEqual(4, messageDataCrate.Content.AllValues().ToList().Count, "Message fields are not getting populated when Send SMS is executed."); var twilioService = Mock.Get(ObjectFactory.GetInstance <ITwilioService>()); twilioService.Verify(t => t.SendSms(It.IsAny <string>(), It.IsAny <string>())); }
public async Task Initialize__CheckConfigControls() { //Arrage _sendSmsActivity = New <Send_SMS_v1>(); //Act var activityContext = new ActivityContext { HubCommunicator = ObjectFactory.GetInstance <IHubCommunicator>(), ActivityPayload = new ActivityPayload { CrateStorage = new CrateStorage() } }; await _sendSmsActivity.Configure(activityContext); //Assert var configControls = activityContext.ActivityPayload.CrateStorage.CratesOfType <StandardConfigurationControlsCM>().Single(); Assert.IsNotNull(configControls, "Send SMS is not initialized properly."); Assert.IsTrue(configControls.Content.Controls.Count == 2, "Send SMS configuration controls are not created correctly."); }