示例#1
0
        public async Task Echoes()
        {
            // arrange
            var message = "Some Message";

            var factory = Mock.Of <IGrainFactory>();

            Mock.Get(factory)
            .Setup(x => x.GetGrain <IEchoGrain>(Guid.Empty, null).EchoAsync(message))
            .Returns(new ValueTask <string>(message));

            var controller = new EchoController(factory);

            RequestContext.ActivityId = Guid.NewGuid();

            // act
            var result = await controller.GetAsync(message).ConfigureAwait(false);

            // assert
            var ok    = Assert.IsType <OkObjectResult>(result.Result);
            var value = Assert.IsType <Echo>(ok.Value);

            Assert.Equal(RequestContext.ActivityId, value.ActivityId);
            Assert.Equal(message, value.Message);
            Assert.Equal("0", value.Version);
        }
示例#2
0
 /// <summary>Initialize other echo controller. Use it between Ready and Go methods.</summary>
 /// <param name="c">New custom echo controller.</param>
 public void SetEchoCtrl(SEcho c)
 {
     if (SP.ContainsKey(1))
     {
         return;
     }
     EchoCtrl = c; // The method will be run when Echo Controller is not runned
 }
示例#3
0
        public void GetNotPassingEchoShouldReturnBadRequest()
        {
            var controller = new EchoController();

            var response = controller.Get(null);

            Assert.IsType <BadRequestResult>(response);
        }
示例#4
0
        public async Task Test()
        {
            var controller = new EchoController(NullLogger <EchoController> .Instance);
            var message    = "message";
            var response   = await controller.Post(message, CancellationToken.None);

            Assert.Contains(message, response.Message);
        }
示例#5
0
        public void GetPassingEchoShouldReturnOk()
        {
            var controller = new EchoController();

            var response = controller.Get("Testing");

            var okResult = Assert.IsType <OkObjectResult>(response);

            Assert.Equal("Testing", okResult.Value);
        }
示例#6
0
        public void GetTest()
        {
            // arrange
            var logger = XUnitLogger.Create <EchoController>(this.testOutputHelper);
            var sut    = new EchoController(logger);

            // act
            var result = sut.Get();

            // assert
            result.ShouldNotBeNull();
        }
示例#7
0
        public async Task Controller_UnitTest()
        {
            // Arrange
            var    controller = new EchoController(new EchoController.EchoRepoTest());
            int    iUserID    = 1;
            string strValue   = "1234";

            // Act
            var result = await controller.Post_Async(new EchoController.Packet {
                UserID = iUserID, stringValue = strValue
            });


            // Assert
            Assert.Equal(iUserID, result.UserID);
            Assert.Equal(strValue, result.stringValue);
        }
    void CreateTimeLoop()
    {
        GameObject     inst     = Instantiate(echoPrefab, transform.position, transform.rotation);
        EchoController echoCtrl = inst.GetComponent <EchoController>();

        for (int i = 0; i < sendStep; i++)
        {
            echoCtrl.recordArray[i, 0] = (Vector3)sendArray[i, 0];
            echoCtrl.recordArray[i, 1] = (Quaternion)sendArray[i, 1];
            echoCtrl.recordArray[i, 2] = (Quaternion)sendArray[i, 2];
            echoCtrl.recordArray[i, 3] = (bool)sendArray[i, 3];
            echoCtrl.recordArray[i, 4] = (float)sendArray[i, 4];
            echoCtrl.recordArray[i, 5] = (float)sendArray[i, 5];
        }

        echoCtrl.endStep = sendStep;

        print(active);
    }
示例#9
0
 /// <summary>This method used to initialize OS in RSG stage. Do not use it for other.</summary>
 public void Ready(Program p)
 {
     if (P != null)
     {
         return;            // The method will be run once
     }
     P   = p;
     GTS = P.GridTerminalSystem;
     SetCmd(new Dictionary <string, Cmd>
     {
         { "start", new Cmd(CmdRun, "Start initialized subprogram by id.", "/start <id> - Start new subprogram, check id by /isp.") },
         { "stop", new Cmd(CmdStop, "Stop runned subprogram by id.", "/stop <id> - Stop subprogram, check id by /sp.") },
         { "sp", new Cmd(CmdSP, "View runned subprograms or run the subprogram command.", "/sp - View runned subprograms;\n/sp <id> - View runned subprogram information;\n/sp <id> <command> [arguments] - Run the subprogram command.") },
         { "isp", new Cmd(CmdISP, "View initilized subprograms information.", "/isp - View initilized subprograms;\n/isp <id> - View initilized subprogram information.") },
         { "clr", new Cmd(CmdClearC, "Clearing the command interface.") }, // todo переделать под отправителя
     });
     if (EchoCtrl == null)
     {
         EchoCtrl = new SEcho();                   // Initialize default echo controller
     }
     P.Runtime.UpdateFrequency = UpdateFrequency.Update1;
 }
示例#10
0
 public EchoShould()
 {
     controller = new EchoController();
 }