Exemplo n.º 1
0
        public void SaveTrack_Test()
        {
            ILogger       log          = DependencyInjector.DependencyInjectorResolve <ILogger>();
            IFilterRebels filterRebels = DependencyInjector.DependencyInjectorResolve <IFilterRebels>();
            RebelSightingRepositoryFile rebelSightingRepositoryFile = new RebelSightingRepositoryFile(log);

            rebelSightingRepositoryFile.FilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\testFile.txt");;
            if (File.Exists(rebelSightingRepositoryFile.FilePath))
            {
                File.Delete(rebelSightingRepositoryFile.FilePath);
            }
            IRebelTrack rebelTrack = new RebelTrack(rebelSightingRepositoryFile, filterRebels, log);

            var rebelName  = "Luke";
            var planetName = "Tatooine";
            var result     = rebelTrack.SaveTrack(rebelName, planetName);

            Assert.AreEqual(true, result);

            File.Delete(rebelSightingRepositoryFile.FilePath);
        }
Exemplo n.º 2
0
        public void ReadAll_Test()
        {
            ILogger       log          = DependencyInjector.DependencyInjectorResolve <ILogger>();
            IFilterRebels filterRebels = DependencyInjector.DependencyInjectorResolve <IFilterRebels>();
            RebelSightingRepositoryFile rebelSightingRepositoryFile = new RebelSightingRepositoryFile(log);

            rebelSightingRepositoryFile.FilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\testFile.txt");;
            if (File.Exists(rebelSightingRepositoryFile.FilePath))
            {
                File.Delete(rebelSightingRepositoryFile.FilePath);
            }
            IRebelTrack rebelTrack = new RebelTrack(rebelSightingRepositoryFile, filterRebels, log);

            rebelTrack.SaveTrack("Luke", "Tatooine");
            rebelTrack.SaveTrack("Han Solo", "Corellia");
            var result = rebelTrack.ReadAll().Count();

            Assert.AreEqual(2, result);

            File.Delete(rebelSightingRepositoryFile.FilePath);
        }
Exemplo n.º 3
0
        public void ReadByName_Test()
        {
            ILogger       log          = DependencyInjector.DependencyInjectorResolve <ILogger>();
            IFilterRebels filterRebels = DependencyInjector.DependencyInjectorResolve <IFilterRebels>();
            RebelSightingRepositoryFile rebelSightingRepositoryFile = new RebelSightingRepositoryFile(log);

            rebelSightingRepositoryFile.FilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\testFile.txt");;
            if (File.Exists(rebelSightingRepositoryFile.FilePath))
            {
                File.Delete(rebelSightingRepositoryFile.FilePath);
            }
            IRebelTrack rebelTrack = new RebelTrack(rebelSightingRepositoryFile, filterRebels, log);
            WebService1 ws1        = new WebService1(rebelTrack, log);

            ws1.RebelSighting("Luke", "Tantooine");
            ws1.RebelSighting("Han Solo", "Corellia");
            ws1.RebelSighting("Leia", "Endor");
            var result = ws1.ReadByName("Luke").Count();

            Assert.AreEqual(1, result);

            File.Delete(rebelSightingRepositoryFile.FilePath);
        }