Exemplo n.º 1
0
        public void ForceSignOutThrowsOnUnexpectedResponseStatus()
        {
            var user = GetUser("username");
            var request = MockRepository.GenerateStub<IRequest>();
            user.RequestFactory.Stub(r => r.CreateForceUserSignOutRequest(user.Username)).Return(request);
            var response = new Response
            {
                Status = HttpStatusCode.BadRequest,
                Body = "errorMessage"
            };
            var errorData = new ErrorData
            {
                status = (int)response.Status,
                message = response.Body
            };
            user.JsonSerializer.Stub(j => j.Deserialize<ErrorData>(response.Body)).Return(errorData);
            user.RestClient.Stub(r => r.Execute(request)).Return(response);

            Assert.Throws<BeaconpushException>(() => user.ForceSignOut());
        }
Exemplo n.º 2
0
        public void SendThrowsOnUnexpectedResponseStatus()
        {
            var channel = GetChannel("name");
            channel.JsonSerializer.Stub(j => j.Serialize("message")).Return("message");
            var request = MockRepository.GenerateStub<IRequest>();
            channel.RequestFactory.Stub(r => r.CreateSendMessageToChannelRequest(channel.Name, "message")).Return(request);
            var response = new Response
            {
                Status = HttpStatusCode.BadRequest,
                Body = "errorMessage"
            };
            var errorData = new ErrorData
            {
                status = (int)response.Status,
                message = response.Body
            };
            channel.JsonSerializer.Stub(j => j.Deserialize<ErrorData>(response.Body)).Return(errorData);
            channel.RestClient.Stub(r => r.Execute(request)).Return(response);

            Assert.Throws<BeaconpushException>(() => channel.Send("message"));
        }
Exemplo n.º 3
0
        public void OnlineUserCountThrowsOnUnexpectedResponseStatus()
        {
            var beacon = GetBeacon();
            var request = MockRepository.GenerateStub<IRequest>();
            beacon.RequestFactory.Stub(r => r.CreateOnlineUserCountRequest()).Return(request);
            var response = new Response
            {
                Status = HttpStatusCode.BadRequest,
                Body = "errorMessage"
            };
            var errorData = new ErrorData
            {
                status = (int)response.Status,
                message = response.Body
            };
            beacon.JsonSerializer.Stub(j => j.Deserialize<ErrorData>(response.Body)).Return(errorData);
            beacon.RestClient.Stub(r => r.Execute(request)).Return(response);

            Assert.Throws<BeaconpushException>(() => beacon.OnlineUserCount());
        }