예제 #1
0
파일: Test4.cs 프로젝트: LenaLenina/TDD
        public static void Test4_ReportManagerCreateSimpleReport()
        {
            MockRepository rhinoEngine = new MockRepository();
            var            mockWriter  = rhinoEngine.DynamicMock <TextWriter>();

            TextWriterFactory.SetTextWriter(mockWriter);

            using (rhinoEngine.Record())
            {
                mockWriter.Write("Nothing");

                LastCall.Constraints(new Rhino.Mocks.Constraints.Contains("TestCustomer") &
                                     new Rhino.Mocks.Constraints.Contains("TestMovie") &
                                     new Rhino.Mocks.Constraints.Contains("6 days") &
                                     new Rhino.Mocks.Constraints.Contains(12.ToString("C")) &
                                     new Rhino.Mocks.Constraints.Contains("(Regular)"));

                mockWriter.Flush();
            }

            Customer customer = new Customer("TestCustomer");

            customer.Rentals.Add(new Renatal(Movie.RegularMovie("TestMovie"), 6));

            ReportManager.CreateSimpleReport("SomePath", customer);

            rhinoEngine.VerifyAll();
        }
        public void Test_Create_SimpleReport()
        {
            MockRepository mockRepository = new MockRepository();
            var            mockObject     = mockRepository.DynamicMock <TextWriter>();

            TextWriterFactory.SetTextWriter(mockObject);

            using (mockRepository.Record())
            {
                mockObject.Write("Something");
                LastCall.Constraints(new Rhino.Mocks.Constraints.Contains("Client report Name: TestCustomer") &
                                     new Rhino.Mocks.Constraints.Contains("Scooter rent Name: TestName") &
                                     new Rhino.Mocks.Constraints.Contains("Scooter type: Honda") &
                                     new Rhino.Mocks.Constraints.Contains("Price rent coast: 7") &
                                     new Rhino.Mocks.Constraints.Contains("Days rent: 6") &
                                     new Rhino.Mocks.Constraints.Contains("Total rent coast: 42") &
                                     new Rhino.Mocks.Constraints.Contains("Total customer dept: 42"));
            }
            Customer customer = new Customer("TestCustomer");

            customer.Rentals.Add(new Rental(Scooter.Honda("TestName"), 6));
            ReportManager.CreateSimpleReport("SomePath", customer);
            mockRepository.VerifyAll();
        }