示例#1
0
        static void Main()
        {
            /* // First example
            Context context;
            context = new Context(new ContreteStrategyA());
            context.ContextInterface();

            context = new Context(new ConcreateStrategyB());
            context.ContextInterface();

            // Second example
            SortedList studentRecords = new SortedList();

            studentRecords.Add("Samual");
            studentRecords.Add("Jimmy");
            studentRecords.Add("Sandra");
            studentRecords.Add("Vivek");
            studentRecords.Add("Anna");

            studentRecords.SetSortStrategy(new QuickSort());
            studentRecords.Sort();

            studentRecords.SetSortStrategy(new ShellSort());
            studentRecords.Sort();

            studentRecords.SetSortStrategy(new MergeSort());
            studentRecords.Sort();*/

            // Third example
            Duck m = new DuckFirst();
            m.performFly();
            m.performQuack();

            m = new ModelDuck();
            m.performFly();
            m.performQuack();

            // TDD example
            var reporter = new Reporter(new SimpleReportBuilder(), new SimpleReportSender());
            var reportCount = reporter.SendReports();
            Console.WriteLine(reportCount);
        }
示例#2
0
        public void SendAllReports()
        {
            // arrange
            var reportBuilder = new Mock<IReportBuilder>();
            var reportSender = new Mock<IReportSender>();
            var reporter = new Reporter(reportBuilder.Object, reportSender.Object);

            reportBuilder.Setup(m => m.CreateReports()).Returns(new List<Report>()
                                                                     {
                                                                         new Report(),
                                                                         new Report()
                                                                   });
            // act
            reporter.SendReports();
            // assert
            reportSender.Verify(m => m.Send(It.IsAny<Report>()), Times.Exactly(2));
        }
示例#3
0
 public Tests()
 {
     _reportBuilder = new Mock<IReportBuilder>();
     _reportSender = new Mock<IReportSender>();
     _reporter = new Reporter(_reportBuilder.Object, _reportSender.Object);
 }