예제 #1
0
        public void GetResponse_ReturnsSuccessFalse_OnAuthError()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("auth-error"));

            var sut = new CharacterParser();

            // Act
            Response <Character> result = sut.GetResponse <Character>(json);

            // Assert
            Assert.AreEqual(false, result.Success);
            Assert.AreEqual("InvalidCredentials", result.Code);
            Assert.AreEqual("The passed API key is invalid.", result.Status);
            Assert.IsNull(result.Data);
        }
예제 #2
0
        public void GetResponse_ReturnsSuccessTrue_OnSuccess()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("character-success"));

            var sut = new CharacterParser();

            // Act
            Response <Character> result = sut.GetResponse <Character>(json);

            // Assert
            Assert.AreEqual(true, result.Success);
            Assert.AreEqual("200", result.Code);
            Assert.AreEqual("Success.", result.Status);
            Assert.IsNotNull(result.Data);
        }
예제 #3
0
        public void GetResponse_ReturnsSuccessFalse_OnApiError()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("api-error"));

            var sut = new CharacterParser();

            // Act
            Response <Character> result = sut.GetResponse <Character>(json);

            // Assert
            Assert.AreEqual(false, result.Success);
            Assert.AreEqual("409", result.Code);
            Assert.AreEqual("Limit greater than 100.", result.Status);
            Assert.IsNull(result.Data);
        }