コード例 #1
0
        public async Task ExportAndImportTours()
        {
            var api = new Mock<ITourApi>().Object;
            var filter = new Mock<IFilter>().Object;
            var handler = new DataHandler();
            var tp = new TourPlannerClient(api, handler, filter);
            var tours = new List<Tour>()
            {
                new(1000, "From", "To", "Name", 10.0, "",
                    new List<TourLog>())
            };
            var path = $"{basePath}{Path.DirectorySeparatorChar}export.td";

            var (ok, exportError) = await tp.ExportTours(path, tours);
            var (importedTours, importError) = await tp.ImportTours(path);
            
            Assert.AreEqual("", exportError);
            Assert.IsTrue(ok);
            Assert.AreEqual("", importError);
            Assert.IsNotNull(importedTours);
            // Do not check for equality because the id of imported Tours is always 0
            Assert.AreEqual(tours.First().From, importedTours!.First().From);
            Assert.AreEqual(tours.First().To, importedTours!.First().To);
            Assert.AreEqual(tours.First().Name, importedTours!.First().Name);
            Assert.AreEqual(tours.First().Distance, importedTours!.First().Distance);
            Assert.AreEqual(tours.First().Description, importedTours!.First().Description);
            Assert.AreEqual(tours.First().Logs, importedTours!.First().Logs);
        }
コード例 #2
0
        public void FilterByValidDescription()
        {
            var api     = new Mock <ITourApi>().Object;
            var handler = new Mock <IImportExportHandler>().Object;
            var filter  = new GeneralFilter();
            var tp      = new TourPlannerClient(api, handler, filter);

            tp.UpdateFilter("ed diam nonumy");
            var ok = tp.FilterMethod(tour);

            Assert.IsTrue(ok);
        }
コード例 #3
0
        public void FilterByInvalidRating()
        {
            var api     = new Mock <ITourApi>().Object;
            var handler = new Mock <IImportExportHandler>().Object;
            var filter  = new GeneralFilter();
            var tp      = new TourPlannerClient(api, handler, filter);

            tp.UpdateFilter("Terrible");
            var ok = tp.FilterMethod(tour);

            Assert.IsFalse(ok);
        }
コード例 #4
0
        public async Task ExportTours()
        {
            var api = new Mock<ITourApi>().Object;
            var filter = new Mock<IFilter>().Object;
            var handler = new DataHandler();
            var tp = new TourPlannerClient(api, handler, filter);
            var tours = new List<Tour>()
            {
                new(1000, "From", "To", "Name", 10.0, "",
                    new List<TourLog>())
            };
            var path = $"{basePath}{Path.DirectorySeparatorChar}export.td";

            var (ok, error) = await tp.ExportTours(path, tours);
            
            Assert.AreEqual("", error);
            Assert.IsTrue(ok);
        }