public ReactivePropertyViewModel(IShelfBoxRepository shelfBoxRepository) { _shelfBoxRepository = shelfBoxRepository; BoxDatas = new ObservableCollection <BoxDataEntity>(_shelfBoxRepository.GetBoxAll()); BoxDatas2.Value = new ObservableCollection <BoxDataEntity>(_shelfBoxRepository.GetBoxAll()); Name.Value = "akiraFirst"; //Index2.Subscribe(x => Console.WriteLine($"Subscribe: {x}")).AddTo(this.Disposable); // 1個 Subscribe: 初期値 Index2.Subscribe(x => { Console.WriteLine($"Subscribe: {x}"); Index = x; }).AddTo(this.Disposable); // いろいろ行う Subscribe: 初期値 //NameTest = new ReactiveProperty<string>() //.SetValidateNotifyError(x => string.IsNullOrEmpty(x) ? "空文字はダメ" : null); NameTest = new ReactiveProperty <string>(mode: ReactivePropertyMode.Default | ReactivePropertyMode.IgnoreInitialValidationError) .SetValidateNotifyError(x => string.IsNullOrEmpty(x) ? "空文字はダメ" : null).AddTo(this.Disposable);; // デフォルト値が true の設定 IsChecked = new ReactivePropertySlim <bool>(true).AddTo(this.Disposable); // ReactiveProperty は IObservable なので ReactiveCommand にできる SampleCommand = IsChecked.ToReactiveCommand().AddTo(this.Disposable); // ReactiveCommand は IObservable なので Select で加工して ReactiveProperty に出来る Message = SampleCommand.Select(_ => DateTime.Now.ToString()) .ToReadOnlyReactivePropertySlim().AddTo(this.Disposable); ButtonCommand.Subscribe(_ => ButtonAction()); this.Input = new ReactiveProperty <string>(""); // デフォルト値を指定してReactivePropertyを作成 this.Output = this.Input .Delay(TimeSpan.FromSeconds(1)) // 1秒間待機して .Select(x => x.ToUpper()) // 大文字に変換して .ToReactiveProperty(); // ReactiveProperty化する }
/// <summary> /// Initializes a new instance of the <see cref="SampleCommandTests" /> class. /// </summary> public SampleCommandTests() { _mockedSheetRetriever = new Mock <IElementRetriever>(); _mockedDataTableCreator = new Mock <IDataTableCreator>(); _mockedFilePathSelector = new Mock <IFilePathSelector>(); _mockedDataWriter = new Mock <IDataWriter>(); _mockedSampleProperties = new Mock <IRvtCommandProperties <SampleCommand> >(); _mockedSampleProperties.SetupGet(p => p.Name).Returns("Sample"); _mockedSampleProperties.SetupGet(p => p.DisplayName).Returns("Sample Command"); _mockedDialogService = new Mock <IDialogService>(); _mockedDialogService.Setup(dialogService => dialogService.ShowDialog(It.IsAny <string>(), It.IsAny <string>())).Verifiable(); _emptySampleCommand = GetTestSampleCommand(); _externalCommandData = JustMock.Create <ExternalCommandData>(); _uiApplication = JustMock.Create <UIApplication>(); _uiDocument = JustMock.Create <UIDocument>(); _document = JustMock.Create <Document>(); }
public async Task TestCommandHandlerNoValidationNoResponse() { var request = new SampleCommand(0); var result = await Record.ExceptionAsync(() => GetRequiredService <ICommandBus>().Dispatch(request, CancellationToken.None)); result.Should().BeNull(); }
public async Task <IActionResult> DispatchCommand( [FromServices] IBackgroundDispatcher dispatcher) { var command = new SampleCommand(); await dispatcher.DispatchAsync(command); return(AcceptedAtRoute(nameof(GetCommandStatus), new { id = command.Id })); }
private static void Main() { var cmd = new SampleCommand(); cmd.Run(); cmd.Run(); cmd.Run(); }
public void Nothing() { var repo = A.Fake <IDomainObjectRepository>(); ConventionCommandInvoker sut = GetSut(repo); Type type = typeof(FakeObject); var cmd = new SampleCommand(); }
public async Task ItCallsThepipeline() { var cmd = new SampleCommand(); var pipeline = A.Fake <ICommandPipeline>(); await Execute(pipeline, cmd); A.CallTo(() => pipeline.ExecuteAsync(A <ICommand> .That.IsSameAs(cmd))).MustHaveHappened(); }
public async Task ItIndicatesSucesss() { var cmd = new SampleCommand(); var pipeline = A.Fake <ICommandPipeline>(); CommandBusResult result = await Execute(pipeline, cmd); Assert.True(result.WasSuccessfull); }
public SampleCommand(SampleCommand source) : base(source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } AdditionalProperty = source.AdditionalProperty; InterfaceStringProp = source.InterfaceStringProp; }
public async Task TestCommandHandlerWithResponse() { const int value = 15; var request = new SampleCommand(value); var result = await Record.ExceptionAsync(() => GetRequiredService <ICommandBus>().Dispatch(request, CancellationToken.None)); result.Should().BeNull(); }
public void ItThrowsAtEndOfRetries() { var repo = A.Fake <IDomainObjectRepository>(); A.CallTo(() => repo.SaveAsync(A <IDomainObject> .Ignored, A <bool> .Ignored)) .Returns(AppendResult.WrongVersion(2)); ConventionCommandInvoker sut = GetSut(repo); var cmd = new SampleCommand(); }
public MainViewModel() { SampleImage.Value = new Bitmap(100, 200, PixelFormat.Format24bppRgb); SampleLabel.Value = "A"; SampleCommand.Subscribe(_ => { SampleImage.Value = new Bitmap(200, 100, PixelFormat.Format24bppRgb); }); SampleCommand2.Subscribe(_ => { SampleLabel.Value += "B"; }); }
public async Task <IActionResult> PostAsync() { var command = new SampleCommand { Value = "Value of the Sample Command" }; await _dispatcher.Send(command); return(Ok()); }
public void Bind_InputIsNull_ThrowsException() { // arrange var sut = CreateCommandParameterBinder(); var command = new SampleCommand(); Action sutAction = () => sut.Bind(command, null); // act, assert var ex = Assert.Throws <ArgumentNullException>(sutAction); Assert.Equal("input", ex.ParamName); }
public void SampleCommand_ShouldRunWithNoException(string id, string name, string accountno) { var handler = CommandHandlerFactory.GetCommandHandler <SampleCommand>(); var command = new SampleCommand { Id = id, Name = name, AccountNo = accountno }; Should.NotThrow(() => handler.Handle(command)); }
public async Task ItExecutesWhenConditionIsFullfilled() { var pipeline = A.Fake <ICommandPipeline>(); var command = new SampleCommand { Value = 42 }; CommandBusResult result = await Execute(pipeline, command); Assert.True(result.WasSuccessfull); }
public async Task ItDoesNothingWhenCondingIsNotMet() { var pipeline = A.Fake <ICommandPipeline>(); var command = new SampleCommand { Value = 5 }; CommandBusResult result = await Execute(pipeline, command); Assert.False(result.WasSuccessfull); }
public InvokeCommandControl() { this.InitializeComponent(); UpdateCountCommand = new SampleCommand(); UpdateGreyCommand = new SampleCommand(); UpdatePinkCommand = new SampleCommand(); this.UpdateCountCommand.CanExecuteChanged += UpdateCountCommand_CanExecuteChanged; this.UpdateGreyCommand.CanExecuteChanged += UpdateGreyCommand_CanExecuteChanged; this.UpdatePinkCommand.CanExecuteChanged += UpdatePinkCommand_CanExecuteChanged; this.DataContext = this; darkgreybrush = new SolidColorBrush(); darkgreybrush.Color = Color.FromArgb(255, 51, 51, 50); pinkbrush = new SolidColorBrush(); pinkbrush.Color = Color.FromArgb(255, 233, 95, 91); }
public void SampleCommand_ShouldShowExceptionInConsole(string id, string name, string accountno) { var handler = CommandHandlerFactory.GetCommandHandler <SampleCommand>(); var command = new SampleCommand { Id = id, Name = name, AccountNo = accountno }; using (var sw = new StringWriter()) { // redirect console output to stringwriter Console.SetOut(sw); Should.NotThrow(() => handler.Handle(command)); var expected = "Exception"; var consoleOutput = sw.ToString(); consoleOutput.ShouldContain(expected); } }
public void CommandBus_Shuld_Send_Command_To_Registered_Handler() { // Arrange SampleCommand actual = null; var handler = new Mock <ICommandHander <SampleCommand> >(); handler.Setup(x => x.Handle(It.IsAny <SampleCommand>())).Callback <SampleCommand>(c => actual = c); var resolver = new Mock <IResolver>(); resolver.Setup(x => x.Get(typeof(ICommandHander <SampleCommand>))).Returns(handler.Object); var expected = this.random.Create <SampleCommand>(); var bus = new CommandBus(resolver.Object); // Action bus.Send(expected); // Assert actual.Should().NotBeNull(); actual.Should().BeSameAs(expected); }
public static void Main(string[] args) { Configure(); var serviceProvider = _serviceCollection.BuildServiceProvider(); var app = new CommandLineApplication { Name = "MyCLI" }; app.HelpOption("-h|--help"); app.OnExecute(() => { Console.WriteLine("Hello World!"); return(0); }); var sampleCommand = new SampleCommand(); app.Command(sampleCommand.CommandName, sampleCommand.CommandImplementation); app.Execute(args); }
public Task <BodyResponse <SampleInfo> > Handle(SampleCommand request, CancellationToken cancellationToken) { BodyResponse <SampleInfo> response = new BodyResponse <SampleInfo>(StatusCodeDefines.LoginError, null, null); return(Task.FromResult(response)); }
public async Task <IActionResult> SampleCommand() { var command = new SampleCommand(_NAME); return(await this.HandleRequest(_commandDispatcher, command)); }
protected override IVsDataReader SelectObjects(string typeName, object[] restrictions, string[] properties, object[] parameters) { if (typeName == null) { throw new ArgumentNullException("typeName"); } // Execute a SQL statement to get the property values SampleConnection conn = Site.GetLockedProviderObject() as SampleConnection; Debug.Assert(conn != null, "Invalid provider object."); if (conn == null) { // This should never occur throw new NotSupportedException(); } try { // Ensure the connection is open if (Site.State != DataConnectionState.Open) { Site.Open(); } // Create a command object SampleCommand comm = (SampleCommand)conn.CreateCommand(); // Choose and format SQL based on the type if (typeName.Equals(SqlObjectTypes.Root, StringComparison.OrdinalIgnoreCase)) { comm.CommandText = rootEnumerationSql; } else if (restrictions.Length == 0 || !(restrictions[0] is string)) { throw new ArgumentException( "Missing required restriction(s)."); } else if (typeName.Equals(SqlObjectTypes.Index, StringComparison.OrdinalIgnoreCase)) { comm.CommandText = FormatSqlString( indexEnumerationSql, restrictions, indexEnumerationDefaults); } else if (typeName.Equals(SqlObjectTypes.IndexColumn, StringComparison.OrdinalIgnoreCase)) { comm.CommandText = FormatSqlString( indexColumnEnumerationSql, restrictions, indexColumnEnumerationDefaults); } else if (typeName.Equals(SqlObjectTypes.ForeignKey, StringComparison.OrdinalIgnoreCase)) { comm.CommandText = FormatSqlString( foreignKeyEnumerationSql, restrictions, foreignKeyEnumerationDefaults); } else if (typeName.Equals(SqlObjectTypes.ForeignKeyColumn, StringComparison.OrdinalIgnoreCase)) { comm.CommandText = FormatSqlString( foreignKeyColumnEnumerationSql, restrictions, foreignKeyColumnEnumerationDefaults); } else if (typeName.Equals(SqlObjectTypes.StoredProcedure, StringComparison.OrdinalIgnoreCase)) { comm.CommandText = FormatSqlString( storedProcedureEnumerationSql, restrictions, storedProcedureEnumerationDefaults); } else if (typeName.Equals(SqlObjectTypes.StoredProcedureParameter, StringComparison.OrdinalIgnoreCase)) { comm.CommandText = FormatSqlString( storedProcedureParameterEnumerationSql, restrictions, storedProcedureParameterEnumerationDefaults); } else if (typeName.Equals(SqlObjectTypes.StoredProcedureColumn, StringComparison.OrdinalIgnoreCase)) { if (restrictions.Length < 3 || !(restrictions[0] is string) || !(restrictions[1] is string) || !(restrictions[2] is string)) { throw new ArgumentException( "Missing required restriction(s)."); } // // In order to implement stored procedure columns we // execute the stored procedure in schema only mode // and intepret the resulting schema table. // // Format the command type and text comm.CommandType = CommandType.StoredProcedure; comm.CommandText = String.Format( CultureInfo.CurrentCulture, "[{0}].[{1}].[{2}]", (restrictions[0] as string).Replace("]", "]]"), (restrictions[1] as string).Replace("]", "]]"), (restrictions[2] as string).Replace("]", "]]")); // Get the schema of the stored procedure DataTable schemaTable = null; DbDataReader reader = null; try { // SqlCommandBuilder.DeriveParameters(comm); reader = comm.ExecuteReader(CommandBehavior.SchemaOnly); schemaTable = reader.GetSchemaTable(); } catch (SqlException) { // The DeriveParameters and GetSchemaTable calls can // be flaky; catch SqlException here because we would // rather return an empty result set than an error. } catch (InvalidOperationException) { // DeriveParameters sometimes throws this as well } finally { if (reader != null) { reader.Close(); } } // Build a different data table to contain the right // information (must have full identifier) DataTable dataTable = new DataTable(); dataTable.Locale = CultureInfo.CurrentCulture; dataTable.Columns.Add("Database", typeof(string)); dataTable.Columns.Add("Schema", typeof(string)); dataTable.Columns.Add("StoredProcedure", typeof(string)); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("Ordinal", typeof(int)); dataTable.Columns.Add("ProviderType", typeof(int)); dataTable.Columns.Add("FrameworkType", typeof(Type)); dataTable.Columns.Add("MaxLength", typeof(int)); dataTable.Columns.Add("Precision", typeof(short)); dataTable.Columns.Add("Scale", typeof(short)); dataTable.Columns.Add("IsNullable", typeof(bool)); // Populate the data table if a schema table was returned if (schemaTable != null) { foreach (DataRow row in schemaTable.Rows) { dataTable.Rows.Add( restrictions[0], restrictions[1], restrictions[2], row["ColumnName"], row["ColumnOrdinal"], row["ProviderType"], row["DataType"], row["ColumnSize"], row["NumericPrecision"], row["NumericScale"], row["AllowDBNull"]); } } return(new AdoDotNetTableReader(dataTable)); } else if (typeName.Equals(SqlObjectTypes.Function, StringComparison.OrdinalIgnoreCase)) { comm.CommandText = FormatSqlString( functionEnumerationSql, restrictions, functionEnumerationDefaults); } else if (typeName.Equals(SqlObjectTypes.FunctionParameter, StringComparison.OrdinalIgnoreCase)) { comm.CommandText = FormatSqlString( functionParameterEnumerationSql, restrictions, functionParameterEnumerationDefaults); } else if (typeName.Equals(SqlObjectTypes.FunctionColumn, StringComparison.OrdinalIgnoreCase)) { comm.CommandText = FormatSqlString( functionColumnEnumerationSql, restrictions, functionColumnEnumerationDefaults); } else { throw new NotSupportedException(); } return(new AdoDotNetReader(comm.ExecuteReader())); } finally { Site.UnlockProviderObject(); } }
public async Task <IActionResult> Create([FromBody] SampleCommand command, CancellationToken cancellationToken) { var result = await _mediator.Send(command, cancellationToken); return(FromResult(result)); }
protected bool Equals(SampleCommand other) { return string.Equals(SomeContents, other.SomeContents); }
protected bool Equals(SampleCommand other) { return(string.Equals(SomeContents, other.SomeContents)); }
public async Task <IActionResult> Hello([FromBody] SampleCommand sampleCommand) { var result = await _mediator.Send(sampleCommand); return(Ok(result)); }