Inheritance: ICustomerFormatter, ICustomerDeserializer
示例#1
0
        public void CompositeFormatter_WhenCustomerHaveMultipleRentals_ShouldPass()
        {
            var jsonFormatter = new JsonFormatter();
            var xmlFormatter = new XmlFormatter();
            var standardFormatter = new StandardFormatter();
            var compositeFormatter = new CompositeFormatter();

            compositeFormatter.AddFormatter(new JsonFormatter());
            compositeFormatter.AddFormatter(new StandardFormatter());
            compositeFormatter.AddFormatter(new XmlFormatter());

            var customer = CustomerFactory.GetCustomer();
            var serializedData = customer.GetStatement(compositeFormatter);
            Customer actualFromJson = jsonFormatter.Deserialize(serializedData);
            Customer actualFromXml = xmlFormatter.Deserialize(serializedData);
            Customer actualFromStandard = standardFormatter.Deserialize(serializedData);

            Assert.True(customer.Equals(actualFromJson));
            Assert.True(customer.Equals(actualFromXml));
            Assert.True(customer.Equals(actualFromStandard));
        }
示例#2
0
        public void XmlFormatter_WhenCustomerHaveMultipleRentals_ShouldPass()
        {
            var customer = CustomerFactory.GetCustomer();
            var xmlFormatter = new XmlFormatter();
            var serializedData = customer.GetStatement(xmlFormatter);
            Customer actual = xmlFormatter.Deserialize(serializedData);

            Assert.True(customer.Equals(actual));
        }