public Task Given_EntityFrameworkCore_is_the_registered_repository()
        {
            CurrentHost.Agent().Configuration
            .RegisterComponent(new EntityFrameworkCoreRepositoryComponent(builder => builder.UseInMemoryDatabase("REstateScenarioTests")));

            return(Task.CompletedTask);
        }
예제 #2
0
        public Task Given_a_Schematic_with_an_initial_state_INITIALSTATE(string schematicName, TState initialState)
        {
            CurrentSchematic = CurrentHost.Agent()
                               .CreateSchematic <TState, TInput>(schematicName)
                               .WithState(initialState, state => state
                                          .AsInitialState())
                               .Build();

            return(Task.CompletedTask);
        }
예제 #3
0
 public async Task Given_a_Machine_exists_with_MachineId_MACHINEID(ISchematic <TState, TInput> schematic, string machineId)
 {
     CurrentMachine = await CurrentHost.Agent()
                      .GetStateEngine <TState, TInput>()
                      .CreateMachineAsync(schematic, machineId, new Dictionary <string, string>
     {
         ["Key1"] = "Value1",
         ["Key2"] = "Value2"
     });
 }
        public Task Given_the_default_agent_is_gRPC_remote()
        {
            CurrentHost.Agent().Configuration
            .RegisterComponent(new GrpcRemoteHostComponent(new GrpcHostOptions
            {
                Channel            = new Channel("localhost", CurrentGrpcServer.BoundPorts[0], ChannelCredentials.Insecure),
                UseAsDefaultEngine = true
            }));

            return(Task.CompletedTask);
        }
예제 #5
0
        public Task When_configuration_is_accessed()
        {
            try
            {
                CurrentHostConfiguration = CurrentHost.Agent().Configuration;
            }
            catch (Exception ex)
            {
                CurrentException = ex;
            }

            return(Task.CompletedTask);
        }
예제 #6
0
 public async Task When_a_NaturalStateMachine_is_created(INaturalSchematic naturalSchematic)
 {
     try
     {
         CurrentNaturalStateMachine = await CurrentHost.Agent()
                                      .GetNaturalStateEngine()
                                      .CreateMachineAsync(naturalSchematic);
     }
     catch (Exception ex)
     {
         CurrentException = ex;
     }
 }
예제 #7
0
 public async Task When_MACHINECOUNT_Machines_are_bulk_created_from_a_Schematic(ISchematic <TState, TInput> schematic, int machineCount)
 {
     try
     {
         BulkCreatedMachines = (await CurrentHost.Agent()
                                .GetStateEngine <TState, TInput>()
                                .BulkCreateMachinesAsync(schematic, Enumerable.Repeat(new Dictionary <string, string>(0), machineCount))).ToList();
     }
     catch (Exception ex)
     {
         CurrentException = ex;
     }
 }
예제 #8
0
 public async Task When_a_Machine_is_created_from_a_SchematicName(string schematicName)
 {
     try
     {
         CurrentMachine = await CurrentHost.Agent()
                          .GetStateEngine <TState, TInput>()
                          .CreateMachineAsync(schematicName);
     }
     catch (Exception ex)
     {
         CurrentException = ex;
     }
 }
예제 #9
0
        public async Task Given_a_Schematic_with_an_action_is_stored(string schematicName, TState state, ConnectorKey connectorKey)
        {
            var schematic = CurrentHost.Agent()
                            .CreateSchematic <TState, TInput>(schematicName)
                            .WithState(state, _ => _
                                       .AsInitialState()
                                       .WithAction(connectorKey))
                            .Build();

            await CurrentHost.Agent()
            .GetStateEngine <TState, TInput>()
            .StoreSchematicAsync(schematic);
        }
예제 #10
0
 public async Task When_a_Machine_is_deleted_with_MachineId_MACHINEID(string machineId)
 {
     try
     {
         await CurrentHost.Agent()
         .GetStateEngine <TState, TInput>()
         .DeleteMachineAsync(machineId);
     }
     catch (Exception ex)
     {
         CurrentException = ex;
     }
 }
예제 #11
0
 public async Task When_a_Machine_is_created_from_a_Schematic_with_a_predefined_MachineId(
     ISchematic <TState, TInput> schematic, string machineId)
 {
     try
     {
         CurrentMachine = await CurrentHost.Agent()
                          .GetStateEngine <TState, TInput>()
                          .CreateMachineAsync(schematic, machineId);
     }
     catch (Exception ex)
     {
         CurrentException = ex;
     }
 }
예제 #12
0
        public async Task When_a_NaturalSchematic_is_retrieved(string schematicName)
        {
            try
            {
                CurrentNaturalSchematic = new NaturalSchematic(
                    await CurrentHost.Agent()
                    .GetStateEngine <TypeState, TypeState>()
                    .GetSchematicAsync(schematicName));

                var machine = await CurrentHost.Agent().GetNaturalStateEngine().CreateMachineAsync(CurrentNaturalSchematic);
            }
            catch (Exception ex)
            {
                CurrentException = ex;
            }
        }
예제 #13
0
        public Task Given_EntityFrameworkCore_is_the_registered_repository()
        {
            var options = new DbContextOptionsBuilder()
                          .UseInMemoryDatabase("REstateScenarioTests")
                          //.UseSqlServer(
                          //    "Server=(localdb)\\mssqllocaldb;Database=REstateEfTestsIntegrated;Trusted_Connection=True;MultipleActiveResultSets=true")
                          .Options;

            CurrentHost.Agent().Configuration
            .RegisterComponent(new EntityFrameworkCoreRepositoryComponent(
                                   options));

            //await new REstateDbContextFactory(options).CreateContext().Database.EnsureCreatedAsync(CancellationToken.None);

            return(Task.CompletedTask);
        }
예제 #14
0
 public async Task When_a_Machine_is_created_from_a_Schematic(ISchematic <TState, TInput> schematic)
 {
     try
     {
         CurrentMachine = await CurrentHost.Agent()
                          .GetStateEngine <TState, TInput>()
                          .CreateMachineAsync(schematic, new Dictionary <string, string>
         {
             ["Key1"] = "Value1",
             ["Key2"] = "Value2"
         });
     }
     catch (Exception ex)
     {
         CurrentException = ex;
     }
 }
        public Task When_a_REstate_gRPC_Server_is_created_and_started()
        {
            if (CurrentGrpcServer == null)
            {
                lock (CurrentGrpcServerSyncRoot)
                {
                    if (CurrentGrpcServer == null)
                    {
                        CurrentGrpcServer = CurrentHost.Agent()
                                            .AsRemote()
                                            .CreateGrpcServer(new ServerPort("0.0.0.0", 0, ServerCredentials.Insecure));
                    }
                }
            }

            CurrentGrpcServer.Start();

            return(Task.CompletedTask);
        }
예제 #16
0
파일: Schematics.cs 프로젝트: psibr/REstate
        public Task Given_a_Schematic(Func <IAgent, ISchematic <TState, TInput> > schematic)
        {
            CurrentSchematic = schematic.Invoke(CurrentHost.Agent());

            return(Task.CompletedTask);
        }
예제 #17
0
 public async Task When_a_Schematic_with_an_action_is_retrieved(string schematicName)
 {
     CurrentSchematic = await CurrentHost.Agent()
                        .GetStateEngine <TState, TInput>()
                        .GetSchematicAsync(schematicName);
 }
예제 #18
0
 public async Task Given_a_Schematic_is_stored(ISchematic <TState, TInput> schematic)
 {
     await CurrentHost.Agent()
     .GetStateEngine <TState, TInput>()
     .StoreSchematicAsync(schematic);
 }
예제 #19
0
 public async Task Given_a_NaturalSchematic_is_stored(INaturalSchematic naturalSchematic)
 {
     await CurrentHost.Agent()
     .GetStateEngine <TypeState, TypeState>()
     .StoreSchematicAsync(naturalSchematic);
 }
예제 #20
0
        public Task Given_a_NaturalSchematic()
        {
            CurrentNaturalSchematic = CurrentHost.Agent().ConstructSchematic <ProvisioningSystem>();

            return(Task.CompletedTask);
        }
예제 #21
0
 public async Task Given_a_Machine_exists_with_MachineId_MACHINEID(ISchematic <TState, TInput> schematic, string machineId)
 {
     CurrentMachine = await CurrentHost.Agent()
                      .GetStateEngine <TState, TInput>()
                      .CreateMachineAsync(schematic, machineId);
 }