public void GetMyAddressTest()
        {
            ServiceTest service = new ServiceTest();

            string result = service.GetMyAddress();

            Assert.AreEqual("Køgevej 54a", result);
        }
        public void GetMyNameTest()
        {
            ServiceTest service = new ServiceTest();

            string result = service.GetMyName();

            Assert.AreEqual("Kevin Jensen", result);
        }
        public void If_LogToObj_IsOk()
        {
            //ARRANGE
            String      cmd = "convert https://s3.amazonaws.com/uux-itaas-static/minha-cdn-logs/input-01.txt ./output/minhaCdn1.txt";
            ServiceTest svc = new ServiceTest();

            // ACT
            IReadWriteFile service     = new ReadWriteFile();
            String         docPathSave = service.Inicialize(cmd);
            string         text        = File.ReadAllText(@docPathSave);

            // ASSERT
            Assert.AreEqual(text, svc.GenerateFinalLog().ToString());
        }
예제 #4
0
        static void Main(string[] args)
        {
            #region Remote MR test
            ServiceTest.Test();
            #endregion

            #region Simple product recommendation sample
            //MapReduceDriver prodrec = new MapReduceDriver("configProductRecommendSimple.json");

            //IDictionary sessprod = prodrec.Start();
            #endregion

            #region Simple GREP sample
            //MapReduceDriver grep = new MapReduceDriver("configGrep.json");

            //IDictionary grepresult = grep.Start();
            #endregion

            #region Word count to SQLite JSON
            //MapReduceDriver wordcount = new MapReduceDriver("configWordCountSQLiteJSONoutput.json");

            //IDictionary wordcountresult = wordcount.Start();
            #endregion

            #region Inverted Index - Shakespeare
            //MapReduceDriver dwordcountInv2 = new MapReduceDriver("configInvertedIndex.json");

            //dwordcountInv2.Tasks[0].Output.Location = Guid.NewGuid() + ".db3";

            //IDictionary resultInv2 = dwordcountInv2.Start();
            #endregion

            #region Large product recommendation - depends on external log
            //MapReduceDriver prodRecommDriver = new MapReduceDriver("configProductRecommendLargeLog.json");

            //prodRecommDriver.Start();
            #endregion

            #region Binary inverted index data - depends on external data
            //MapReduceDriver dwordcountInv2 = new MapReduceDriver("configInvertedIndexSQLiteBinaryOutput.json");

            //dwordcountInv2.Tasks[0].Output.Location = "gutenberg.db3";

            //IDictionary resultInv2 = dwordcountInv2.Start();
            #endregion

            #region External merger sample
            //SQLiteExternalMerge.Merge(new InvertedIndexReducer(), new ProtobufSerializer(), "mout.db3", "m1bin.db3", "m2bin.db3");
            #endregion
        }
        public void GetDaysOfWeekTest()
        {
            ServiceTest service = new ServiceTest();

            List <string> result = service.GetDaysOfWeek();

            Assert.AreEqual("Mandag", result[0]);
            Assert.AreEqual("Tirsdag", result[1]);
            Assert.AreEqual("Onsdag", result[2]);
            Assert.AreEqual("Torsdag", result[3]);
            Assert.AreEqual("Fredag", result[4]);
            Assert.AreEqual("Lørdag", result[5]);
            Assert.AreEqual("Søndag", result[6]);
        }
예제 #6
0
        public void If_WriteFile_IsOK()
        {
            //ARRANGE
            ServiceTest svc        = new ServiceTest();
            List <Log>  listOfLogs = svc.GenerateListOfLogs();
            String      fileName   = "./output/test.txt";

            // ACT
            IWriteFile service     = new WriteFile();
            String     docPathSave = service.WriteFile(listOfLogs, fileName);
            string     text        = File.ReadAllText(@docPathSave);

            // ASSERT
            Assert.AreEqual(text, svc.GenerateFinalLog().ToString());
        }
        public void If_LogToObj_IsOk()
        {
            //ARRANGE
            String        url     = "test";
            var           mock    = new Mock <IReadFile>();
            ServiceTest   svc     = new ServiceTest();
            StringBuilder content = svc.GenerateLog();
            MemoryStream  ms      = new MemoryStream(Encoding.UTF8.GetBytes(content.ToString()));

            mock.Setup(library => library.Read(url)).Returns(ms);

            // ACT
            ILogToObject service    = new LogToObject();
            List <Log>   listOfLogs = service.LogToObj(mock.Object, url);

            // ASSERT
            mock.Verify(library => library.Read(url), Times.AtMostOnce());
            Assert.AreEqual(listOfLogs.Count, 4);
        }
예제 #8
0
        static void Main(string[] args)
        {
            Logger.RegisterLogger(new ConsoleLogger());
            Logger.RegisterLogger(new FileDumpLogger(@"L:\log.txt", Encoding.UTF8));

            //AssemblyActivator.ExecuteAll(AppDomain.CurrentDomain.GetAssemblies(), null);
            //
            //var dt = PersianDate.Parse("1394/9/17").ToGregorianDateTime().ToString();
            //Logger.Write(dt);
            //
            //var t = typeof(NewtonsoftJsonSerializer);
            //GC.KeepAlive(t);

            //CityFileGenerator.Start();

            //MapperTest.DoTest();
            ServiceTest.Test();
            //TypeResolverTest.Test();
            //NewtonsoftJsonTest.DoTest();
            //MapperTest.DoTest();
            //QueryableCrudServiceTest.Test();
            //byte[] bytePass = Encoding.Unicode.GetBytes("A.M.K. Website Creator haha you hacked me!");
            //byte[] byteSalt = Convert.FromBase64String("andDhiSISmySUALT");
            //byte[] byteResult = new byte[byteSalt.Length + bytePass.Length];
            //
            //Buffer.BlockCopy(byteSalt, 0, byteResult, 0, byteSalt.Length);
            //Buffer.BlockCopy(bytePass, 0, byteResult, byteSalt.Length, bytePass.Length);
            //
            //HashAlgorithm ha = HashAlgorithm.Create("SHA1");
            //Logger.Write(Convert.ToBase64String(ha.ComputeHash(byteResult)));

            //var ret = new RetryHelper(3);
            //while (!ret.IsDone())
            //{
            //    Logger.Write("Failed");
            //    ret.Fail();
            //}

            Console.ReadKey();
        }
예제 #9
0
        public void If_ReadFile_ReturnElements()
        {
            //Arrange
            String        url = "https://s3.amazonaws.com/uux-itaas-static/minha-cdn-logs/input-01.txt";
            string        line;
            StringBuilder testLog = new StringBuilder();
            ServiceTest   svc     = new ServiceTest();
            StringBuilder logReal = svc.GenerateLog();

            //Act
            IReadFile    read      = new ReadFile();
            Stream       resStream = read.Read(url);
            StreamReader reader    = new StreamReader(resStream);

            while ((line = reader.ReadLine()) != null)
            {
                testLog.AppendLine(line);
            }

            //Assert
            Assert.AreEqual(testLog.ToString(), logReal.ToString());
        }