public async Task EstateDomainService_CreateEstate_EstateIsCreated() { Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> > estateAggregateRepository = new Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> >(); estateAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(new EstateAggregate()); estateAggregateRepository.Setup(m => m.SaveChanges(It.IsAny <EstateAggregate>(), It.IsAny <CancellationToken>())).Returns(Task.CompletedTask); Mock <ISecurityServiceClient> securityServiceClient = new Mock <ISecurityServiceClient>(); EstateDomainService domainService = new EstateDomainService(estateAggregateRepository.Object, securityServiceClient.Object); Should.NotThrow(async() => { await domainService.CreateEstate(TestData.EstateId, TestData.EstateName, CancellationToken.None); }); }
public void UpdateContentDetail_Success() { // Arrange ShimContent.GetByContentIDInt32UserBoolean = (p1, p2, p3) => new ECN_Framework_Entities.Communicator.Content { ContentID = p1 }; for (int i = 1; i <= 9; i++) { var selectedSlot = _testObject.GetFieldOrProperty("HiddenField_SelectedSlot") as HiddenField; selectedSlot.Value = i.ToString(); // Act, Assert Should.NotThrow(() => _testObject.Invoke("updateContentDetail", new object[] { i })); var hdnSlot = _testObject.GetFieldOrProperty("HiddenField_Content" + i) as HiddenField; hdnSlot.Value.ShouldBe(i.ToString()); } }
public void OnNavigatedTo__NavigatesBackOnInvalidBlikCode() { // ARRANGE var mockNavigationService = new Mock <INavigationService>(); var mockDialogService = new Mock <IPageDialogService>(); var mockBlikService = new Mock <IBlikService>(); var viewModel = new BlikCodePageViewModel(mockNavigationService.Object, mockBlikService.Object, mockDialogService.Object) { BlikCode = null }; // ACT Should.NotThrow(() => viewModel.OnNavigatedTo(new Mock <INavigationParameters>().Object)); // ASSERT mockNavigationService.Verify(n => n.GoBackAsync(), Times.Once); }
public async Task success_persist() { var persistedGrant = new PersistedGrant() { ClientId = _clientId, Data = NewGuidS, Key = _key, SubjectId = NewGuidS, Type = NewGuidS, CreationTime = DateTime.UtcNow, Expiration = DateTime.UtcNow.AddMinutes(10) }; Should.NotThrow(() => { StoreAsync(persistedGrant).GetAwaiter(); }); }
public async Task ContractDomainService_DisableTransactionFeeForProduct_TransactionFeeDisabled(CalculationType calculationType, FeeType feeType) { Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> > estateAggregateRepository = new Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> >(); Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> > contractAggregateRepository = new Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> >(); contractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny <Guid>(), It.IsAny <CancellationToken>())) .ReturnsAsync(TestData.CreatedContractAggregateWithAProductAndTransactionFee(calculationType, feeType)); ContractDomainService domainService = new ContractDomainService(estateAggregateRepository.Object, contractAggregateRepository.Object); Should.NotThrow(async() => { await domainService.DisableTransactionFeeForProduct(TestData.TransactionFeeId, TestData.ContractId, TestData.ProductId, CancellationToken.None); }); }
public void LayoutsGrid_Command_DeleteLayout_Success() { // Arrange var eventArgs = new GridViewCommandEventArgs(null, new CommandEventArgs("DeleteLayout", "1")); ShimLayout.DeleteInt32User = (p1, p2) => throw new ECNException(new List <ECNError> { }); _testObject.SetFieldOrProperty("pnlMessage", new UpdatePanel { ID = "1", UpdateMode = UpdatePanelUpdateMode.Conditional }); var isGridLoaded = false; ShimlayoutExplorer.AllInstances.loadLayoutsGridInt32Int32 = (p1, p2, p3) => isGridLoaded = true; // Act, Assert Should.NotThrow(() => _testObject.Invoke("LayoutsGrid_Command", new object[] { null, eventArgs })); isGridLoaded.ShouldBeTrue(); }
public void FileAggregate_CreateFile_FileAlreadyCreated_NoErrorThrown() { FileAggregate fileAggregate = FileAggregate.Create(TestData.FileId); fileAggregate.CreateFile(TestData.FileImportLogId, TestData.EstateId, TestData.MerchantId, TestData.UserId, TestData.FileProfileId, TestData.FileLocation, TestData.FileUploadedDateTime); Should.NotThrow(() => { fileAggregate.CreateFile(TestData.FileImportLogId, TestData.EstateId, TestData.MerchantId, TestData.UserId, TestData.FileProfileId, TestData.FileLocation, TestData.FileUploadedDateTime); }); }
public void a_read_followed_by_a_backward_seek_will_rehydrate_data_correctly_on_the_next_read() { GivenAMemoryStreamContaining(TextInUTF16(new string('x', 2048)), TextInASCII("\r\n--boundary")); GivenAHistoryStreamWithBufferSize(4096); // if buffer is 2048 we need another 2048 to trigger a response ReadBytes(5000).Length.ShouldBe(4096); Stream.Position.ShouldBe(4096); // now the buffer should be full, we seek back by half Should.NotThrow(Executing(() => SeekBy(-2048))); Stream.Position.ShouldBe(4096); // issueing a new read request should trigger a new read on the stream for the leftover text ReadBytes(5000).Length.ShouldBe(4096 - 2048 + 12); Stream.Position.ShouldBe(Stream.Length); }
public void HandicapCalculationCommandHandler_HandleCommand_StartHandicapCalculationProcessForTournamentCommand_CommandHandled() { Mock <IAggregateRepository <HandicapCalculationProcessAggregate> > handicapCalculationProcessRepository = new Mock <IAggregateRepository <HandicapCalculationProcessAggregate> >(); handicapCalculationProcessRepository.Setup(h => h.GetLatestVersion(It.IsAny <Guid>(), CancellationToken.None)) .ReturnsAsync(HandicapCalculationProcessTestData.GetEmptyHandicapCalculationProcessAggregate()); Mock <IAggregateRepository <TournamentAggregate> > tournamentRepository = new Mock <IAggregateRepository <TournamentAggregate> >(); tournamentRepository.Setup(t => t.GetLatestVersion(It.IsAny <Guid>(), CancellationToken.None)) .ReturnsAsync(TournamentTestData.GetCompletedTournamentAggregateWithCSSCalculatedAggregate()); HandicapCalculationCommandHandler handler = new HandicapCalculationCommandHandler(handicapCalculationProcessRepository.Object, tournamentRepository.Object); StartHandicapCalculationProcessForTournamentCommand command = HandicapCalculationProcessTestData.GetStartHandicapCalculationProcessForTournamentCommand(); Should.NotThrow(async() => { await handler.Handle(command, CancellationToken.None); }); }
public void When_executing_multiple_tasks_that_cancel_before_timeout() { using (var cts = new CancellationTokenSource(1.Seconds())) { var cToken = cts.Token; var task1 = DoSomethingAfter(3.Seconds(), cToken); var task2 = DoSomethingAfter(3.Seconds(), cToken); var task3 = DoSomethingAfter(3.Seconds(), cToken); var tasks = new[] { task1, task2, task3 }; Should.NotThrow(async() => { await tasks.TimeoutAfter(4.Seconds()); }); } }
private static void When_publishing_with_no_subscribers() { var aggregator = MessageHub.Instance; Should.NotThrow(() => aggregator.Publish(TimeSpan.FromTicks(1234))); string result = null; aggregator.RegisterGlobalHandler((type, msg) => { type.ShouldBe(typeof(string)); msg.ShouldBeOfType <string>(); result = msg as string; }); aggregator.Publish("654321"); result.ShouldBe("654321"); }
public void should_reject_move_if_cell_already_occupied() { var board = new Board(); int x = 0, y = 2; // add move to unoccupied cell: succeeds Should.NotThrow(() => { board.AddMove(x, y); }); // add move to occupied cell: fails Should.Throw <ArgumentException>(() => { board.AddMove(x, y); }); }
public void PrePopProfileFieldsList_ItemDataBound_Footer_Success() { // Arrange InitilizeTestObjects(); var item = new DataListItem(0, ListItemType.Footer); var Add_ProfileFieldNameDR = new DropDownList { ID = "Add_ProfileFieldNameDR" }; item.Controls.Add(Add_ProfileFieldNameDR); var args = new DataListItemEventArgs(item); ShimSmartFormsPrePopFields.GetColumnNamesInt32Int32 = (p1, p2) => new DataTable { }; // Act, Assert Should.NotThrow(() => privateObject.Invoke("PrePopProfileFieldsList_ItemDataBound", new object[] { null, args })); }
public void GolfClubCommandHandler_HandleCommand_CreateMatchSecretaryCommand_CommandHandled() { Mock <IAggregateRepository <GolfClubAggregate> > repository = new Mock <IAggregateRepository <GolfClubAggregate> >(); repository.Setup(r => r.GetLatestVersion(It.IsAny <Guid>(), CancellationToken.None)).ReturnsAsync(GolfClubTestData.GetCreatedGolfClubAggregate); Mock <ISecurityService> oAuth2SecurityService = new Mock <ISecurityService>(); Mock <IGolfClubMembershipApplicationService> golfClubMembershipApplicationService = new Mock <IGolfClubMembershipApplicationService>(); GolfClubCommandHandler handler = new GolfClubCommandHandler(repository.Object, oAuth2SecurityService.Object, golfClubMembershipApplicationService.Object); oAuth2SecurityService .Setup(o => o.RegisterUser(It.IsAny <RegisterUserRequest>(), CancellationToken.None)) .ReturnsAsync(GolfClubTestData.GetRegisterUserResponse()); CreateMatchSecretaryCommand command = GolfClubTestData.GetCreateMatchSecretaryCommand(); Should.NotThrow(async() => { await handler.Handle(command, CancellationToken.None); }); }
public void When_publishing_with_no_subscribers() { var hub = new MessageHub(); Should.NotThrow(() => hub.Publish(TimeSpan.FromTicks(1234))); string result = null; hub.RegisterGlobalHandler((type, msg) => { type.ShouldBe(typeof(string)); msg.ShouldBeOfType <string>(); result = msg as string; }); hub.Publish("654321"); result.ShouldBe("654321"); }
public void GetBlikCodeCommand__ShouldNotNavigateOnInvalidCredentials(string username) { // ARRANGE var parameters = new NavigationParameters { { nameof(username), username }, }; var mockNavigationService = new Mock <INavigationService>(); var viewModel = new AccountPageViewModel(mockNavigationService.Object); // ACT Should.NotThrow(() => viewModel.OnNavigatingTo(parameters)); // ASSERT viewModel.GetBlikCodeCommand.CanExecute().ShouldBeFalse(); }
public void ShouldNotErrorIfUnmappedCachedMappingMemberIsIgnored() { Should.NotThrow(() => { var exampleSource = new { LaLaLa = default(int) }; using (var mapper = Mapper.CreateNew()) { mapper.WhenMapping .From(exampleSource).To <PublicField <int> >() .Ignore(pf => pf.Value); mapper.GetPlanFor(exampleSource).OnTo <PublicField <int> >(); mapper.ThrowNowIfAnyMappingPlanIsIncomplete(); } }); }
public void for_document_with_int_id_when_schema_patch_applied_then_does_not_show_more_changes() { theStore.Tenancy.Default.EnsureStorageExists(typeof(IntDoc)); using (var store = DocumentStore.For(_ => { _.Connection(ConnectionSource.ConnectionString); _.Schema.For <IntDoc>(); })) { Should.NotThrow(() => { store.Schema.ApplyAllConfiguredChangesToDatabase(); store.Schema.AssertDatabaseMatchesConfiguration(); }); } }
public void When_retrying_a_func_that_does_not_fail_on_multiple_exceptions() { Should.NotThrow(async() => { var counter = 0; var result = await Retry.OnAny <ArgumentNullException, NullReferenceException, int>( () => { counter++; return(42); }, 100.Milliseconds(), 100.Milliseconds(), 100.Milliseconds()); counter.ShouldBe(1); result.ShouldBe(42); }); }
public void ShouldNotErrorIfAbstractMemberHasDiscoverableDerivedTypePairs() { Should.NotThrow(() => { using (var mapper = Mapper.CreateNew()) { mapper.WhenMapping.ThrowIfAnyMappingPlanIsIncomplete(); mapper.WhenMapping .From <Issue183.ThingBase>().ButNotDerivedTypes .To <Issue183.ThingDto>() .Ignore(t => t.Value); mapper.GetPlanFor <PublicField <Issue183.ThingBase> >() .ToANew <PublicField <Issue183.ThingBaseDto> >(); } }); }
public void VerifyInsertWithNullValues() { // Arrange var statement = new InsertSqlStatement("My_magic_table"); statement.Columns.AddRange(new[] { "Column A", "Column B", "Column C" }); statement.Rows.Add(new List <object> { "Value A", 123, null }); // Act string generatedQuery = null; Should.NotThrow(() => generatedQuery = statement.GenerateQuery()); // Assert string.IsNullOrEmpty(generatedQuery).ShouldBeFalse(); }
public void Remove() { var td = new TypeDictionary <IServiceCollection, IServiceProvider> { [typeof(ServiceCollection)] = typeof(ServiceProvider) }; td.Count.ShouldBe(1); td.ShouldContainKey(typeof(ServiceCollection)); Should.Throw <ArgumentNullException>(() => td.Remove(null)); Should.Throw <ArgumentException>(() => td.Remove(typeof(ServiceProvider))); Should.NotThrow(() => td.Remove(typeof(IServiceCollection))).ShouldBeFalse(); td.Count.ShouldBe(1); td.ShouldContainKey(typeof(ServiceCollection)); Should.NotThrow(() => td.Remove(typeof(ServiceCollection))).ShouldBeTrue(); td.Count.ShouldBe(0); td.ShouldNotContainKey(typeof(ServiceCollection)); }
public void SaveContent_DefaultEditor_WithContent_Success([Values(true, false)] bool withUserId) { // Arrange var rblContentType = _testObject.GetFieldOrProperty("rblContentType") as RadioButtonList; rblContentType.Items.Add("false"); rblContentType.SelectedValue = "false"; var folderID = _testObject.GetFieldOrProperty("folderID") as DropDownList; folderID.Items.Add("0"); folderID.SelectedValue = "0"; var txtEditorSource = _testObject.GetFieldOrProperty("txtEditorSource") as TextBox; txtEditorSource.Text = "test1"; var txtEditorMobile = _testObject.GetFieldOrProperty("txtEditorMobile") as TextBox; txtEditorMobile.Text = "test2"; var drpUserID = _testObject.GetFieldOrProperty("drpUserID") as DropDownList; drpUserID.Items.Add("0"); drpUserID.Items.Add("1"); QueryString.Add("ContentID", "1"); if (withUserId) { drpUserID.SelectedValue = "1"; } else { drpUserID.SelectedValue = "0"; } ECN_Framework_Entities.Communicator.Content content = null; ShimContent.SaveContentUser = (p1, p2) => { content = p1; return(0); }; ShimContent.GetByContentIDInt32UserBoolean = (p1, p2, p3) => new ECN_Framework_Entities.Communicator.Content { IsValidated = true, CreatedUserID = 1 }; // Act, Assert Should.NotThrow(() => _testObject.Invoke("SaveContent", new object[] { })); content.ShouldSatisfyAllConditions( () => content.ShouldNotBeNull(), () => content.ContentSource.ShouldBe("test1"), () => content.ContentMobile.ShouldBe("test2")); }
public void NestedBlockLambdaScenarioShouldFail() { Verify.ShouldFail(() => { Should.NotThrow(() => { if (true) { throw new Exception("Dummy message."); } }, () => "Additional info"); }, errorWithSource: @"`if (true) { throw new Exception(""Dummy message.""); }` should not throw but threw System.Exception with message ""Dummy message."" Additional Info: Additional info", errorWithoutSource: #if net40 || net45 @"Task should not throw but threw System.Exception with message ""Dummy message."" Additional Info: Additional info"); #else @"delegate should not throw but threw System.Exception with message ""Dummy message."" Additional Info: Additional info"); #endif }
public void BtnConvertoInlineCSS_Click_Success([Values(true, false)] bool withEditor, [Values(true, false)] bool withExisting) { // Arrange var rblContentType = _testObject.GetFieldOrProperty("rblContentType") as RadioButtonList; rblContentType.Items.Add("True"); rblContentType.Items.Add("False"); rblContentType.SelectedValue = withEditor.ToString(); var fCKeditor1 = _testObject.GetFieldOrProperty("FCKeditor1") as TextBox; var contentText = _testObject.GetFieldOrProperty("ContentText") as TextBox; var txtEditorSource = _testObject.GetFieldOrProperty("txtEditorSource") as TextBox; contentText.Text = "content"; if (withExisting) { txtEditorSource.Text = "text from editor"; fCKeditor1.Text = "FCK Editor"; } // Act, Assert Should.NotThrow(() => _testObject.Invoke("btnConvertoInlineCSS_Click", new object[] { null, null })); if (withEditor) { if (withExisting) { fCKeditor1.Text.ShouldBe("FCK Editor"); } else { fCKeditor1.Text.ShouldBe("content"); } } else { if (withExisting) { txtEditorSource.Text.ShouldBe("text from editor"); } else { txtEditorSource.Text.ShouldBe("content"); } } }
public void Init() { var mock = new Mock <TagHelper>(); mock.Setup(t => t.Process(It.IsAny <TagHelperContext>(), It.IsAny <TagHelperOutput>())) .Callback <TagHelperContext, TagHelperOutput>((c, o) => { o.TagName = "div"; o.Content.Append("test"); }).CallBase(); mock.Setup(t => t.Init(It.IsAny <TagHelperContext>())).CallBase().Verifiable(); var tagHelper = mock.Object; var tagHelperContext = new TagHelperContext( new TagHelperAttributeList(), new Dictionary <object, object>(), Guid.NewGuid().ToString("N")); Should.NotThrow(() => tagHelper.Init(tagHelperContext)); }
public void ShouldNotErrorIfMembersAreMatchedByAToTargetDataSource() { Should.NotThrow(() => { using (var mapper = Mapper.CreateNew()) { mapper.WhenMapping.ThrowIfAnyMappingPlanIsIncomplete(); mapper.WhenMapping .From <PublicField <Address> >() .To <Address>() .Map((pf, _) => pf.Value) .ToTarget(); mapper.GetPlanFor <PublicField <Address> >() .ToANew <PublicTwoFields <Address, Address> >(); } }); }
public void ShouldNotErrorIfUnconstructableComplexTypeMemberHasConfiguredFactoryMethod() { Should.NotThrow(() => { using (var mapper = Mapper.CreateNew()) { mapper.WhenMapping .From <Address>() .ToANew <PublicCtor <string> >() .CreateInstancesUsing(ctx => new PublicCtor <string>(ctx.Source.Line1)); mapper .GetPlanFor <PublicField <Address> >() .ToANew <PublicField <PublicCtor <string> > >(); mapper.ThrowNowIfAnyMappingPlanIsIncomplete(); } }); }
public void Initialize_Facebook_WithoutLongLiveToken_Error() { // Arrange InitilizeAssertObjects(); InitilizeFakes(); InitilizeIntFakes(); InitilizeIntObject(); _appSettings["FBUserID"] = "2"; _queryString.Add("simple", "fb"); _queryString.Add("campaignitemtype", "1"); _queryString.Add("code", "1"); ShimSocialMediaHelper.GetFBAccessTokenStringString = (code, url) => new Dictionary <string, string> { { "access_token", "1" } }; // Act, Assert Should.NotThrow(() => _testObject.Invoke("Initialize")); }
public void FileImportLogAggregate_CreateImportLog_AlreadyCreated_SilentlyHandled() { FileImportLogAggregate fileImportLogAggregate = FileImportLogAggregate.Create(TestData.FileImportLogId); fileImportLogAggregate.CreateImportLog(TestData.EstateId, TestData.ImportLogDateTime); FileImportLog fileImportLog = fileImportLogAggregate.GetFileImportLog(); fileImportLog.ShouldNotBeNull(); fileImportLog.FileImportLogId.ShouldBe(TestData.FileImportLogId); fileImportLog.EstateId.ShouldBe(TestData.EstateId); fileImportLog.FileImportLogDateTime.ShouldBe(TestData.ImportLogDateTime); Should.NotThrow(() => { fileImportLogAggregate.CreateImportLog(TestData.EstateId, TestData.ImportLogDateTime); }); }