Example #1
0
        public void CanConvertWorksForSingleResult(Type type, bool expected)
        {
            // Arrange
            JSingleResultValueConverter converter = new JSingleResultValueConverter();

            // Act & Assert
            Assert.Equal(expected, converter.CanConvert(type));
        }
Example #2
0
        public void CanWriteSingleResultToJsonUsingNewtonsoftJsonConverter()
        {
            // Arrange
            SingleResult <SingleCustomer> pageResult = new SingleResult <SingleCustomer>(_customers);
            JSingleResultValueConverter   converter  = new JSingleResultValueConverter();

            // Act
            string json = SerializeUtils.WriteJson(converter, pageResult);

            // Assert
            Assert.Equal("{\"Id\":1,\"Name\":\"XU\"}", json);
        }
Example #3
0
        public void ReadJsonForSingleResultThrowsNotImplementedException()
        {
            // Arrange
            JSingleResultValueConverter converter = new JSingleResultValueConverter();

            // Act
            Action test = () => converter.ReadJson(null, typeof(object), null, null);

            // Assert
            NotImplementedException exception = Assert.Throws <NotImplementedException>(test);

            Assert.Equal(SRResources.ReadSingleResultNotImplemented, exception.Message);
        }