예제 #1
0
        public void SplitBills_ShouldReturnListOfTripsThatContainsExpensesOwnedPerPerson()
        {
            string filePath = Path.GetFullPath("Resources/testfile.txt");

            decimal[] expected = new decimal[] { -1.99m, -8.01m, 10.01m, 0.98m, -0.98m };

            IFileReader         fileReader = new TextFileReader();
            IFileWriter         fileWriter = new TextFileWriter();
            IExpensesCalculator calculator = new ExpensesCalculator();

            SplitBillsService service = new SplitBillsService(fileReader, fileWriter, calculator);
            bool isSuccess            = service.SplitBills(filePath);

            Assert.True(isSuccess);

            int i = 0;

            foreach (var trip in service.Trips)
            {
                foreach (var participant in trip.Participants)
                {
                    Assert.Equal(expected[i++], participant.ExpensesShouldBePaid);
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            IFileReader         fileReader = new TextFileReader();
            IFileWriter         fileWriter = new TextFileWriter();
            IExpensesCalculator calculator = new ExpensesCalculator();

            IService service = new SplitBillsService(fileReader, fileWriter, calculator);

            service.Serve();
        }
예제 #3
0
        public void SplitBills_ShouldNotSplitBillsWhenGivenIncorrectDataFile()
        {
            string filePath = Path.GetFullPath("Resources/IncorrectDatatestFile.txt");

            IFileReader         fileReader = new TextFileReader();
            IFileWriter         fileWriter = new TextFileWriter();
            IExpensesCalculator calculator = new ExpensesCalculator();

            SplitBillsService service = new SplitBillsService(fileReader, fileWriter, calculator);
            bool isSuccess            = service.SplitBills(filePath);

            Assert.False(isSuccess);
        }