コード例 #1
0
 public SimpleCustomer(string name, DateTime?registrationDate, IYearCounter yearCounter, IShoppingCart cart)
 {
     Name             = name;
     RegistrationDate = registrationDate;
     _yearCounter     = yearCounter;
     Cart             = cart;
 }
コード例 #2
0
 public ValuableCustomerParser(IYearCounter yearCounter, IShoppingCart shoppingCart)
 {
     _yearCounter  = yearCounter;
     _shoppingCart = shoppingCart;
     CanParseType  = (int)CustomerTypes.ValuableCustomer;
 }
コード例 #3
0
ファイル: Class1.cs プロジェクト: jenozsolttoth/L2Module1
            List <ICustomerParser> GetParsers(Customer testCustomer, IShoppingCart shoppingCart, IYearCounter yearCounter)
            {
                Mock <ICustomerParser> nonRegisteredCustomerParser = new Mock <ICustomerParser>();

                nonRegisteredCustomerParser.SetupGet(m => m.CanParseType).Returns(1);
                nonRegisteredCustomerParser.Setup(x => x.ParseCustomer(testCustomer.Name, testCustomer.RegistrationDate)).Returns(new NonRegisteredCustomer(testCustomer.Name, testCustomer.RegistrationDate, shoppingCart));

                Mock <ICustomerParser> simpleCustomerParser = new Mock <ICustomerParser>();

                simpleCustomerParser.SetupGet(m => m.CanParseType).Returns(2);
                simpleCustomerParser.Setup(x => x.ParseCustomer(testCustomer.Name, testCustomer.RegistrationDate)).Returns(new SimpleCustomer(testCustomer.Name, testCustomer.RegistrationDate, yearCounter, shoppingCart));

                Mock <ICustomerParser> valuableCustomerParser = new Mock <ICustomerParser>();

                valuableCustomerParser.SetupGet(m => m.CanParseType).Returns(3);
                valuableCustomerParser.Setup(x => x.ParseCustomer(testCustomer.Name, testCustomer.RegistrationDate)).Returns(new ValuableCustomer(testCustomer.Name, testCustomer.RegistrationDate, yearCounter, shoppingCart));

                Mock <ICustomerParser> mostValuableCustomerParser = new Mock <ICustomerParser>();

                mostValuableCustomerParser.SetupGet(m => m.CanParseType).Returns(4);
                mostValuableCustomerParser.Setup(x => x.ParseCustomer(testCustomer.Name, testCustomer.RegistrationDate)).Returns(new MostValuableCustomer(testCustomer.Name, testCustomer.RegistrationDate, yearCounter, shoppingCart));

                var parsers = new List <ICustomerParser>();

                parsers.Add(nonRegisteredCustomerParser.Object);
                parsers.Add(simpleCustomerParser.Object);
                parsers.Add(valuableCustomerParser.Object);
                parsers.Add(mostValuableCustomerParser.Object);

                return(parsers);
            }
コード例 #4
0
 public NonRegisteredCustomerParser(IYearCounter yearCounter, IShoppingCart shoppingCart)
 {
     _yearCounter  = yearCounter;
     _shoppingCart = shoppingCart;
     CanParseType  = (int)CustomerTypes.NonRegisteredCustomer;
 }
コード例 #5
0
 public SimpleCustomerParser(IYearCounter yearCounter, IShoppingCart shoppingCart)
 {
     _yearCounter  = yearCounter;
     _shoppingCart = shoppingCart;
     CanParseType  = (int)CustomerTypes.SimpleCostumer;
 }