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 StandardFormatter_WhenCustomerHaveMultipleRentals_ShouldPass()
        {
            var customer = CustomerFactory.GetCustomer();
            var standardFormatter = new StandardFormatter();
            var serializedData = customer.GetStatement(standardFormatter);
            Customer actual = standardFormatter.Deserialize(serializedData);

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