コード例 #1
0
        public void Deserialize_SerializedObjectParameterIsNull_ArgumentNullExceptionIsThrown()
        {
            // Arrange
            var jsonObjectSerializer = new JSONObjectSerializer<PublishConfiguration>();
            string serializedObject = null;

            // Act
            jsonObjectSerializer.Deserialize(serializedObject);
        }
コード例 #2
0
        public void Deserialize_PublishConfiguration_SerializedObjectIsValidJson_ResultIsNotNull()
        {
            // Arrange
            var jsonObjectSerializer = new JSONObjectSerializer<PublishConfiguration>();

            var name = Guid.NewGuid().ToString();
            var location = Guid.NewGuid().ToString();
            var apiKey = Guid.NewGuid().ToString();
            string serializedObject = string.Format("{{ Name: \"{0}\", PublishLocation: \"{1}\", ApiKey: \"{2}\" }}", name, location, apiKey);

            // Act
            var result = jsonObjectSerializer.Deserialize(serializedObject);

            // Assert
            Assert.IsNotNull(result);
        }
コード例 #3
0
        public void Deserialize_PublishConfiguration_SerializedObjectIsValidJson_ResultContainsCorrectProperties()
        {
            // Arrange
            var jsonObjectSerializer = new JSONObjectSerializer<PublishConfiguration>();

            var name = Guid.NewGuid().ToString();
            var location = Guid.NewGuid().ToString();
            var apiKey = Guid.NewGuid().ToString();
            string serializedObject = string.Format("{{ Name: \"{0}\", PublishLocation: \"{1}\", ApiKey: \"{2}\" }}", name, location, apiKey);

            // Act
            var result = jsonObjectSerializer.Deserialize(serializedObject);

            // Assert
            Assert.AreEqual(name, result.Name);
            Assert.AreEqual(location, result.PublishLocation);
            Assert.AreEqual(apiKey, result.ApiKey);
        }