public void ProcessFilterQueryListViewItemSelectedIsTrueAndFilterContainEntityLogicalName() { string inputEntityLogicalName = "contact"; bool listViewItemIsSelected = true; var inputFilterQuery = new Dictionary <string, string> { { inputEntityLogicalName, inputEntityLogicalName } }; NotificationServiceMock.Setup(x => x.DisplayFeedback(It.IsAny <string>())) .Verifiable(); var currentfilter = inputFilterQuery[inputEntityLogicalName]; using (var filterDialog = new FilterEditor(currentfilter, System.Windows.Forms.FormStartPosition.CenterParent)) { filterDialog.QueryString = "< filter type =\"and\" > < condition attribute =\"sw_appointmentstatus\" operator=\"eq\" value=\"266880017\" /></ filter >"; FluentActions.Invoking(() => systemUnderTest.ProcessFilterQuery(NotificationServiceMock.Object, null, inputEntityLogicalName, listViewItemIsSelected, inputFilterQuery, filterDialog)) .Should() .NotThrow(); } NotificationServiceMock.Verify(x => x.DisplayFeedback(It.IsAny <string>()), Times.Never); }
public void HandleMappingControlItemClickListViewItemSelectedIsTrueAndFilterContainsEntityLogicalName() { string inputEntityLogicalName = "contact"; bool listViewItemIsSelected = true; var entityReference = new EntityReference(inputEntityLogicalName, Guid.NewGuid()); var mappingItem = new List <Item <EntityReference, EntityReference> > { new Item <EntityReference, EntityReference>(entityReference, entityReference) }; var inputMapping = new Dictionary <string, List <Item <EntityReference, EntityReference> > > { { inputEntityLogicalName, mappingItem } }; var inputMapper = new Dictionary <string, Dictionary <Guid, Guid> >(); NotificationServiceMock.Setup(x => x.DisplayFeedback(It.IsAny <string>())) .Verifiable(); FluentActions.Invoking(() => systemUnderTest.HandleMappingControlItemClick(NotificationServiceMock.Object, inputEntityLogicalName, listViewItemIsSelected, inputMapping, inputMapper, null)) .Should() .NotThrow(); NotificationServiceMock.Verify(x => x.DisplayFeedback(It.IsAny <string>()), Times.Never); }
public void ProcessFilterQueryListViewFilterDialogQueryStringIsEmpty() { string inputEntityLogicalName = "contact"; bool listViewItemIsSelected = true; Dictionary <string, string> inputFilterQuery = new Dictionary <string, string> { { inputEntityLogicalName, inputEntityLogicalName } }; NotificationServiceMock.Setup(x => x.DisplayFeedback(It.IsAny <string>())) .Verifiable(); var currentfilter = inputFilterQuery[inputEntityLogicalName]; using (var filterDialog = new FilterEditor(currentfilter, System.Windows.Forms.FormStartPosition.CenterParent)) { filterDialog.QueryString = string.Empty; FluentActions.Invoking(() => systemUnderTest.ProcessFilterQuery(NotificationServiceMock.Object, null, inputEntityLogicalName, listViewItemIsSelected, inputFilterQuery, filterDialog)) .Should() .NotThrow(); } NotificationServiceMock.Verify(x => x.DisplayFeedback(It.IsAny <string>()), Times.Never); }
public void StoreLookUpAttributeWithLookupAttributeMetadataButEmptyTargetList() { var attributeLogicalName = "contactId"; string primaryAttribute = "contactId"; var crmField = new Capgemini.Xrm.DataMigration.Model.CrmField() { PrimaryKey = false, FieldName = primaryAttribute, FieldType = "entityreference" }; var attribute = new LookupAttributeMetadata { LogicalName = attributeLogicalName, DisplayName = new Label { UserLocalizedLabel = new LocalizedLabel { Label = attributeLogicalName } } }; NotificationServiceMock.Setup(x => x.DisplayFeedback("The supplied attribute is null. Expecting an Entity Reference!")) .Verifiable(); FluentActions.Invoking(() => systemUnderTest.StoreLookUpAttribute(attribute, crmField, NotificationServiceMock.Object)) .Should() .NotThrow(); NotificationServiceMock.Verify(x => x.DisplayFeedback("The supplied attribute is null. Expecting an Entity Reference!"), Times.Never); crmField.LookupType.Should().BeNull(); }
public void ExceptionThrownOnNonPositiveAmount([Values(-1, 0)] decimal amount) { Action transferAction = () => withdrawMoney.Execute( TestAccountFactory.Ids.DefaultFrom, amount); transferAction.Should().Throw <InvalidOperationException>(); // Ensure that no notifications were sent NotificationServiceMock.Verify(x => x.NotifyApproachingPayInLimit(It.IsAny <string>()), Times.Never); NotificationServiceMock.Verify(x => x.NotifyFundsLow(It.IsAny <string>()), Times.Never); // Ensure that the account was not updated AccountRepositoryMock.Verify(x => x.Update(It.IsAny <Account>()), Times.Never); }
public void UserNotifiedOnFundsLow() { var amount = 1m; withdrawMoney.Execute( TestAccountFactory.Ids.FundsLow, amount); // TODO: Shouldn't be creating a new account here just to get its email var fromAccount = TestAccountFactory.NewFundsLow(); // Ensure that only funds low notification sent NotificationServiceMock.Verify(x => x.NotifyApproachingPayInLimit(It.IsAny <string>()), Times.Never); NotificationServiceMock.Verify(x => x.NotifyFundsLow(fromAccount.User.Email), Times.Once); }
public void ToUserNotifiedOnApproachingPayInLimit() { var amount = 1m; transferMoney.Execute( TestAccountFactory.Ids.DefaultFrom, TestAccountFactory.Ids.ApproachingPayInLimit, amount); // TODO: Shouldn't be creating a new account here just to get its email var fromAccount = TestAccountFactory.NewFundsLow(); // Ensure that only approaching pay in limit notification sent NotificationServiceMock.Verify(x => x.NotifyApproachingPayInLimit(It.IsAny <string>()), Times.Once); NotificationServiceMock.Verify(x => x.NotifyFundsLow(fromAccount.User.Email), Times.Never); }
public void HandleMappingControlItemClickNoListViewItemSelected() { string inputEntityLogicalName = "contact"; bool listViewItemIsSelected = false; var inputMapping = new Dictionary <string, List <Item <EntityReference, EntityReference> > >(); var inputMapper = new Dictionary <string, Dictionary <Guid, Guid> >(); NotificationServiceMock.Setup(x => x.DisplayFeedback(It.IsAny <string>())) .Verifiable(); FluentActions.Invoking(() => systemUnderTest.HandleMappingControlItemClick(NotificationServiceMock.Object, inputEntityLogicalName, listViewItemIsSelected, inputMapping, inputMapper, null)) .Should() .NotThrow(); NotificationServiceMock.Verify(x => x.DisplayFeedback(It.IsAny <string>()), Times.Once); }
public void GenerateExportConfigFileWithoutExportConfigFilePath() { var inputFilterQuery = new Dictionary <string, string>(); var inputLookupMaping = new Dictionary <string, Dictionary <string, List <string> > >(); using (var exportConfig = new System.Windows.Forms.TextBox()) { using (var schemaPath = new System.Windows.Forms.TextBox()) { FluentActions.Invoking(() => systemUnderTest.GenerateExportConfigFile(exportConfig, schemaPath, inputFilterQuery, inputLookupMaping, NotificationServiceMock.Object)) .Should() .NotThrow(); } } NotificationServiceMock.Verify(x => x.DisplayFeedback(It.IsAny <string>()), Times.Once); }
public void ExceptionThrownOnInsufficientFunds() { var amount = TestAccountFactory.DefaultBalance + 1m; Action withdrawalAction = () => withdrawMoney.Execute( TestAccountFactory.Ids.DefaultFrom, amount); withdrawalAction.Should().Throw <InvalidOperationException>(); // Ensure that no notifications were sent NotificationServiceMock.Verify(x => x.NotifyApproachingPayInLimit(It.IsAny <string>()), Times.Never); NotificationServiceMock.Verify(x => x.NotifyFundsLow(It.IsAny <string>()), Times.Never); // Ensure that the account was not updated AccountRepositoryMock.Verify(x => x.Update(It.IsAny <Account>()), Times.Never); }
public void PopulateEntitiesListViewWhenThereIsNoException() { var items = new List <System.Windows.Forms.ListViewItem>(); Exception exception = null; NotificationServiceMock.Setup(x => x.DisplayWarningFeedback(It.IsAny <System.Windows.Forms.IWin32Window>(), It.IsAny <string>())) .Verifiable(); using (var listView = new System.Windows.Forms.ListView()) { FluentActions.Invoking(() => systemUnderTest.PopulateEntitiesListView(items, exception, null, listView, NotificationServiceMock.Object)) .Should() .NotThrow(); } NotificationServiceMock.Verify(x => x.DisplayErrorFeedback(It.IsAny <System.Windows.Forms.IWin32Window>(), It.IsAny <string>()), Times.Never); NotificationServiceMock.Verify(x => x.DisplayWarningFeedback(It.IsAny <System.Windows.Forms.IWin32Window>(), It.IsAny <string>()), Times.Once); }
public void LoadImportConfigFileWithNoImportConfig() { var inputMapper = new Dictionary <string, Dictionary <Guid, Guid> >(); var inputMapping = new Dictionary <string, List <Item <EntityReference, EntityReference> > >(); NotificationServiceMock.Setup(x => x.DisplayFeedback(It.IsAny <string>())) .Verifiable(); using (var importConfig = new System.Windows.Forms.TextBox()) { FluentActions.Invoking(() => systemUnderTest.LoadImportConfigFile(NotificationServiceMock.Object, importConfig, inputMapper, inputMapping)) .Should() .NotThrow(); } NotificationServiceMock.Verify(x => x.DisplayFeedback(It.IsAny <string>()), Times.Never); }
public void ExceptionThrownOnFromToSameAccount() { var amount = 1m; Action transferAction = () => transferMoney.Execute( TestAccountFactory.Ids.DefaultFrom, TestAccountFactory.Ids.DefaultFrom, amount); transferAction.Should().Throw <InvalidOperationException>(); // Ensure that no notifications were sent NotificationServiceMock.Verify(x => x.NotifyApproachingPayInLimit(It.IsAny <string>()), Times.Never); NotificationServiceMock.Verify(x => x.NotifyFundsLow(It.IsAny <string>()), Times.Never); // Ensure that neither account was updated AccountRepositoryMock.Verify(x => x.Update(It.IsAny <Account>()), Times.Never); }
public void ProcessFilterQueryNoListViewItemSelected() { string inputEntityLogicalName = "contact"; bool listViewItemIsSelected = false; Dictionary <string, string> inputFilterQuery = new Dictionary <string, string>(); NotificationServiceMock.Setup(x => x.DisplayFeedback(It.IsAny <string>())) .Verifiable(); using (var filterDialog = new FilterEditor(null, System.Windows.Forms.FormStartPosition.CenterParent)) { FluentActions.Invoking(() => systemUnderTest.ProcessFilterQuery(NotificationServiceMock.Object, null, inputEntityLogicalName, listViewItemIsSelected, inputFilterQuery, filterDialog)) .Should() .NotThrow(); } NotificationServiceMock.Verify(x => x.DisplayFeedback(It.IsAny <string>()), Times.Once); }
public void OnPopulateRelationshipCompletedActionWithoutException() { Exception exception = null; bool cancelled = false; var result = new List <System.Windows.Forms.ListViewItem>(); var eventArgs = new System.ComponentModel.RunWorkerCompletedEventArgs(result, exception, cancelled); NotificationServiceMock.Setup(x => x.DisplayErrorFeedback(It.IsAny <System.Windows.Forms.IWin32Window>(), It.IsAny <string>())) .Verifiable(); using (var listView = new System.Windows.Forms.ListView()) { FluentActions.Invoking(() => systemUnderTest.OnPopulateCompletedAction(eventArgs, NotificationServiceMock.Object, null, listView)) .Should() .NotThrow(); } NotificationServiceMock.Verify(x => x.DisplayErrorFeedback(It.IsAny <System.Windows.Forms.IWin32Window>(), It.IsAny <string>()), Times.Never); }
public void StoreLookUpAttributeLookupAttributeMetadataIsNull() { string primaryAttribute = "contactId"; var crmField = new Capgemini.Xrm.DataMigration.Model.CrmField() { PrimaryKey = false, FieldName = primaryAttribute, FieldType = "entityreference" }; NotificationServiceMock.Setup(x => x.DisplayFeedback("The supplied attribute is null. Expecting an Entity Reference!")) .Verifiable(); FluentActions.Invoking(() => systemUnderTest.StoreLookUpAttribute(null, crmField, NotificationServiceMock.Object)) .Should() .NotThrow(); NotificationServiceMock.Verify(x => x.DisplayFeedback("The supplied attribute is null. Expecting an Entity Reference!"), Times.Once); }
public void LoadImportConfigFileHandleException() { var inputMapper = new Dictionary <string, Dictionary <Guid, Guid> >(); var inputMapping = new Dictionary <string, List <Item <EntityReference, EntityReference> > >(); NotificationServiceMock.Setup(x => x.DisplayFeedback("Guid Id Mappings loaded from Import Config File")) .Throws <Exception>(); using (var importConfig = new System.Windows.Forms.TextBox()) { importConfig.Text = "TestData/ImportConfig2.json"; FluentActions.Invoking(() => systemUnderTest.LoadImportConfigFile(NotificationServiceMock.Object, importConfig, inputMapper, inputMapping)) .Should() .NotThrow(); } NotificationServiceMock.Verify(x => x.DisplayFeedback(It.IsAny <string>()), Times.Exactly(2)); }
public void SaveSchemaNoEntityAttributeSelected() { NotificationServiceMock.Setup(x => x.DisplayFeedback("Please select at least one attribute for each selected entity!")) .Verifiable(); using (var schemaPathTextBox = new System.Windows.Forms.TextBox()) { var serviceParameters = GenerateMigratorParameters(); var inputAttributeMapping = new AttributeTypeMapping(); var inputCrmSchemaConfiguration = new DataMigration.Config.CrmSchemaConfiguration(); FluentActions.Invoking(() => systemUnderTest.SaveSchema(serviceParameters, inputCheckedEntity, inputEntityRelationships, inputEntityAttributes, inputAttributeMapping, inputCrmSchemaConfiguration, schemaPathTextBox)) .Should() .NotThrow(); } NotificationServiceMock.Verify(x => x.DisplayFeedback("Please select at least one attribute for each selected entity!"), Times.Once); }
public async Task NotificationsAreSentWhenAppropriate(bool saveSuccessful) { await Task.Delay(InitializationDelayMs); if (!saveSuccessful) { Target.SetGameId(null); } var result = await Target.SaveStateAsync(SlotID, TestSavePayload); Assert.Equal(saveSuccessful, result); var expectedBody = string.Format(StateSavedToSlotMessageBody, SlotID); var expectedTimes = saveSuccessful ? Times.Once() : Times.Never(); NotificationServiceMock.Verify(d => d.Show(StateSavedToSlotMessageTitle, expectedBody, 0), expectedTimes); await Target.ClearSavesAsync(); }
public void LoadExportConfigFileWithEmptyExportConfigPath() { string exportConfigFilename = string.Empty; var inputFilterQuery = new Dictionary <string, string>(); var inputLookupMaping = new Dictionary <string, Dictionary <string, List <string> > >(); NotificationServiceMock.Setup(x => x.DisplayFeedback(It.IsAny <string>())) .Verifiable(); using (System.Windows.Forms.TextBox exportConfigTextBox = new System.Windows.Forms.TextBox()) { exportConfigTextBox.Text = exportConfigFilename; FluentActions.Invoking(() => systemUnderTest.LoadExportConfigFile(NotificationServiceMock.Object, exportConfigTextBox, inputFilterQuery, inputLookupMaping)) .Should() .NotThrow(); } NotificationServiceMock.Verify(x => x.DisplayFeedback(It.IsAny <string>()), Times.Never); }
public void LoadExportConfigFileWithValidExportConfigPath() { string exportConfigFilename = "TestData\\ExportConfig.json"; var inputFilterQuery = new Dictionary <string, string>(); var inputLookupMaping = new Dictionary <string, Dictionary <string, List <string> > >(); NotificationServiceMock.Setup(x => x.DisplayFeedback("Filters and Lookup Mappings loaded from Export Config File")) .Verifiable(); using (System.Windows.Forms.TextBox exportConfigTextBox = new System.Windows.Forms.TextBox()) { exportConfigTextBox.Text = exportConfigFilename; FluentActions.Invoking(() => systemUnderTest.LoadExportConfigFile(NotificationServiceMock.Object, exportConfigTextBox, inputFilterQuery, inputLookupMaping)) .Should() .NotThrow(); } NotificationServiceMock.Verify(x => x.DisplayFeedback("Filters and Lookup Mappings loaded from Export Config File"), Times.Once); }
public void GenerateImportConfigFileWithoutImportConfigFilePath() { var inputMapper = new Dictionary <string, Dictionary <Guid, Guid> >(); var value = new Dictionary <Guid, Guid> { { Guid.NewGuid(), Guid.NewGuid() } }; inputMapper.Add("contact", value); NotificationServiceMock.Setup(x => x.DisplayFeedback(It.IsAny <string>())) .Verifiable(); using (var importConfig = new System.Windows.Forms.TextBox()) { FluentActions.Invoking(() => systemUnderTest.GenerateImportConfigFile(NotificationServiceMock.Object, importConfig, inputMapper)) .Should() .NotThrow(); } NotificationServiceMock.Verify(x => x.DisplayFeedback(It.IsAny <string>()), Times.Once); }
public void LoadSchemaFileWithEmptyExportConfigPath() { string schemaFilename = string.Empty; var inputEntityAttributes = new Dictionary <string, HashSet <string> >(); NotificationServiceMock.Setup(x => x.DisplayFeedback(It.IsAny <string>())) .Verifiable(); using (var systemUnderTest = new SchemaWizard()) { systemUnderTest.OrganizationService = ServiceMock.Object; systemUnderTest.MetadataService = MetadataServiceMock.Object; systemUnderTest.NotificationService = NotificationServiceMock.Object; FluentActions.Invoking(() => systemUnderTest.LoadSchemaFile(schemaFilename, workingstate, NotificationServiceMock.Object, inputEntityAttributes, inputEntityRelationships)) .Should() .NotThrow(); } NotificationServiceMock.Verify(x => x.DisplayFeedback(It.IsAny <string>()), Times.Never); }
public void SaveSchemaEntityAttributeSelected() { NotificationServiceMock.Setup(x => x.DisplayFeedback("Please select at least one attribute for each selected entity!")) .Verifiable(); var entityLogicalName = "contact"; var entityMetadata = InstantiateEntityMetaData(entityLogicalName); InsertAttributeList(entityMetadata, new List <string> { "contactId", "firstname", "lastname" }); inputCheckedEntity.Add(entityLogicalName); var attributeSet = new HashSet <string>() { "contactId", "firstname", "lastname" }; inputEntityAttributes.Add(entityLogicalName, attributeSet); var inputAttributeMapping = new AttributeTypeMapping(); var serviceParameters = GenerateMigratorParameters(); MetadataServiceMock.Setup(x => x.RetrieveEntities(It.IsAny <string>(), It.IsAny <IOrganizationService>(), It.IsAny <IExceptionService>())) .Returns(entityMetadata) .Verifiable(); using (var schemaPathTextBox = new System.Windows.Forms.TextBox()) { var inputCrmSchemaConfiguration = new DataMigration.Config.CrmSchemaConfiguration(); FluentActions.Invoking(() => systemUnderTest.SaveSchema(serviceParameters, inputCheckedEntity, inputEntityRelationships, inputEntityAttributes, inputAttributeMapping, inputCrmSchemaConfiguration, schemaPathTextBox)) .Should() .NotThrow(); } MetadataServiceMock.VerifyAll(); NotificationServiceMock.Verify(x => x.DisplayFeedback("Please select at least one attribute for each selected entity!"), Times.Never); }
public void StoreLookUpAttributeNotLookupAttributeMetadata() { var attributeLogicalName = "contactId"; string primaryAttribute = "contactId"; var crmField = new Capgemini.Xrm.DataMigration.Model.CrmField() { PrimaryKey = false, FieldName = primaryAttribute, FieldType = "entityreference" }; var attribute = new AttributeMetadata { LogicalName = attributeLogicalName, DisplayName = new Label { UserLocalizedLabel = new LocalizedLabel { Label = attributeLogicalName } } }; var attributeTypeName = attribute.GetType().GetRuntimeFields().First(a => a.Name == "_attributeTypeDisplayName"); attributeTypeName.SetValue(attribute, new AttributeTypeDisplayName { Value = attributeLogicalName }); NotificationServiceMock.Setup(x => x.DisplayFeedback("The supplied attribute is null. Expecting an Entity Reference!")) .Verifiable(); FluentActions.Invoking(() => systemUnderTest.StoreLookUpAttribute(attribute, crmField, NotificationServiceMock.Object)) .Should() .NotThrow(); NotificationServiceMock.Verify(x => x.DisplayFeedback("The supplied attribute is null. Expecting an Entity Reference!"), Times.Once); }