public void ReadAll_Test()
        {
            ILogger log = new LoggerLog4Net();
            RebelSightingRepositoryFile rebelSightingRepositoryFile = new RebelSightingRepositoryFile(log);

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

            rebelSightingRepositoryFile.Add("Luke", "Tatooine");
            rebelSightingRepositoryFile.Add("Han Solo", "Corellia");
            var nFilas = rebelSightingRepositoryFile.ReadAll().Count();

            Assert.AreEqual(2, nFilas);

            File.Delete(rebelSightingRepositoryFile.FilePath);
        }
        public void Add_Test()
        {
            ILogger log = new LoggerLog4Net();
            RebelSightingRepositoryFile rebelSightingRepositoryFile = new RebelSightingRepositoryFile(log);

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

            var rebelName  = "Luke";
            var planetName = "Tatooine";
            var success    = rebelSightingRepositoryFile.Add(rebelName, planetName);

            Assert.AreEqual(true, success);

            File.Delete(rebelSightingRepositoryFile.FilePath);
        }
예제 #3
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);
        }
예제 #4
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);
        }
        public void ReadLastLine_Test()
        {
            ILogger log = new LoggerLog4Net();
            RebelSightingRepositoryFile rebelSightingRepositoryFile = new RebelSightingRepositoryFile(log);

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

            var rebelName  = "Luke";
            var planetName = "Tatooine";

            rebelSightingRepositoryFile.Add(rebelName, planetName);
            var lastLine = rebelSightingRepositoryFile.ReadLastEntry();
            var contains = lastLine.Contains(rebelName + " on " + planetName + " at ");

            Assert.AreEqual(true, contains);

            File.Delete(rebelSightingRepositoryFile.FilePath);
        }
예제 #6
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);
        }