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); }
/// <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 }
public void GetNotPassingEchoShouldReturnBadRequest() { var controller = new EchoController(); var response = controller.Get(null); Assert.IsType <BadRequestResult>(response); }
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); }
public void GetPassingEchoShouldReturnOk() { var controller = new EchoController(); var response = controller.Get("Testing"); var okResult = Assert.IsType <OkObjectResult>(response); Assert.Equal("Testing", okResult.Value); }
public void GetTest() { // arrange var logger = XUnitLogger.Create <EchoController>(this.testOutputHelper); var sut = new EchoController(logger); // act var result = sut.Get(); // assert result.ShouldNotBeNull(); }
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); }
/// <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; }
public EchoShould() { controller = new EchoController(); }