Beispiel #1
0
        public void MasterDetailsNoBaseVM_Request()
        {
            var client   = _hubEmulator.CreateClient();
            var response = client.Connect(_detailsVMId).As <dynamic>();

            Assert.AreEqual(int.MaxValue, (int)response.Value);
        }
Beispiel #2
0
        public void AsyncVM_Request()
        {
            var client   = _hubEmulator.CreateClient();
            var response = client.Connect(nameof(AsyncVM)).As <dynamic>();

            Assert.AreEqual(2, (double)response.Value);
        }
Beispiel #3
0
        public void RuntimeVM_Request()
        {
            var client   = _hubEmulator.CreateClient();
            var response = client.Connect("HelloWorldRuntimeVM").As <dynamic>();

            Assert.AreEqual("Hello", (string)response.FirstName);
            Assert.AreEqual("World", (string)response.LastName);
            Assert.AreEqual("Hello World", (string)response.FullName);
        }
Beispiel #4
0
        public void SerializerVM_Serialize()
        {
            var client   = _hubEmulator.CreateClient();
            var response = client.Connect(nameof(SerializerVM)).As <dynamic>();

            Assert.AreEqual("Hello", (string)response.FirstName);
            Assert.AreEqual("World", (string)response.LastName);
            Assert.AreEqual("Hello World", (string)response.FullName);
        }
Beispiel #5
0
        public void ExampleSimpleList_Connect_ReturnsInitialState()
        {
            var response = _hubEmulator
                           .CreateClient()
                           .Connect(nameof(SimpleListVM))
                           .As <ClientState>();

            Assert.AreEqual(2, response.Employees.Count);
        }
        public void BasicReactiveNoBaseVM_Request()
        {
            var client   = _hubEmulator.CreateClient();
            var response = client.Connect(nameof(BasicReactiveNoBaseVM)).As <dynamic>();

            Assert.AreEqual("Hello", (string)response.FirstName);
            Assert.AreEqual("World", (string)response.LastName);
            Assert.AreEqual("Hello World", (string)response.FullName);
        }
        public void ExampleSecurePage_Connect_NoAuthToken_ReturnsNoSecureData()
        {
            var client = _hubEmulator.CreateClient();

            client.Connect(nameof(SecurePageVM));
            var state = client.GetState <ClientState>();

            Assert.IsNull(state.SecureCaption);
            Assert.IsNull(state.SecureData);
        }
        public void ExampleHelloWorld_Connect_ReturnsInitialState()
        {
            var client = _hubEmulator.CreateClient();

            var response = client.Connect(nameof(HelloWorldVM)).As <ClientState>();

            Assert.AreEqual("Hello", response.FirstName);
            Assert.AreEqual("World", response.LastName);
            Assert.AreEqual("Hello World", response.FullName);
        }
        public void ExampleLiveChart_Connect_ReturnsInitialState()
        {
            var response = _hubEmulator
                           .CreateClient()
                           .Connect(nameof(LiveChartVM))
                           .As <ClientState>();

            Assert.AreEqual(60, response.Waveform.Length);
            Assert.AreEqual(8, response.Bar.Length);
            Assert.AreEqual(3, response.Pie.Length);
        }
        public void CrudVMNoBaseVM_Create()
        {
            var client = _hubEmulator.CreateClient();

            client.Connect(nameof(CrudVMNoBaseVM));

            client.Dispatch(new Dictionary <string, object>()
            {
                { "Add", "Peter Chen" }
            });

            var employee = _employeeService.GetAll().Last();

            Assert.AreEqual("Peter", employee.FirstName);
            Assert.AreEqual("Chen", employee.LastName);
        }
Beispiel #11
0
        public void ExampleChatRoom_UserConnects_OtherUserIsNotified()
        {
            var expectedClient1CorrelationId = "0.123";
            var expectedClient2CorrelationId = "0.456";

            var client1 = _hubEmulator.CreateClient();
            var client2 = _hubEmulator.CreateClient();

            client1.Connect(nameof(ChatRoomVM));
            client1.Dispatch(new { AddUser = expectedClient1CorrelationId });

            var client2Response = client2.Connect(nameof(ChatRoomVM)).As <ClientState>();

            Assert.AreEqual(1, client2Response.Users.Count);
            Assert.AreEqual(expectedClient1CorrelationId, client2Response.Users[0].CorrelationId);

            var client1Responses = client1.Listen(() =>
            {
                client2.Dispatch(new { AddUser = expectedClient2CorrelationId });
            });

            Assert.AreEqual(1, client1Responses.Count);
            Assert.AreEqual(expectedClient2CorrelationId, (string)client1Responses.As <dynamic>().Users_add.CorrelationId);
            Assert.IsTrue(client1.GetState <ClientState>().Users.Any(x => x.CorrelationId == expectedClient2CorrelationId));
        }
        public void ExampleControlTypes_SetTextBox_ReturnsTextBoxResult()
        {
            var client = _hubEmulator.CreateClient();

            var initialState = client.Connect(nameof(ControlTypesVM)).As <dynamic>();
            var response     = client.Dispatch(new { TextBoxValue = "testing" }).As <dynamic>();

            Assert.AreEqual("Type something here", (string)initialState.TextBoxPlaceHolder);
            Assert.AreEqual("You typed: testing", (string)response.TextBoxResult);
        }