Пример #1
0
 public CustomerMenu(SavvyContext context, DBMapper mapper)
 {
     this.repo   = new SavvyRepo(context, mapper);
     productMenu = new ProductMenu(context, mapper, customer);
     cartMenu    = new CartMenu();
     //orderhistorymenu = new OrderHistoryMenu(context, mapper);
 }
Пример #2
0
        public async Task AddAnalysisAsyncShouldHandleErrorsAsync()
        {
            //arrange
            var options = new DbContextOptionsBuilder <YouTubeJamContext>()
                          .UseInMemoryDatabase("AddAnalysisAsyncShouldHandleErrorsAsync")
                          .Options;

            using var context = new YouTubeJamContext(options);
            var mapper = new DBMapper(context);
            var repo   = new Repository(context, mapper);

            BusinessLogic.Creator b = new BusinessLogic.Creator()
            {
                Email       = "*****@*****.**",
                ChannelName = "Mathemartian"
            };
            AverageSentiment avg = new AverageSentiment()
            {
                VideoURL = "Abc",
                AverageSentimentScore = 0.5
            };

            //act
            try
            {
                await repo.AddAnalysisAsync(avg, b);

                Assert.True(false);
            } catch (CreatorDoesNotExistException)
            {
                //assert
                Assert.True(true);
            }
        }
Пример #3
0
        public async Task ChannelNameShouldBeUniqueTest2Async()
        {
            //arrange
            var options = new DbContextOptionsBuilder <YouTubeJamContext>()
                          .UseInMemoryDatabase("ChannelNameShouldBeUniqueTest2")
                          .Options;

            using var context = new YouTubeJamContext(options);
            var mapper = new DBMapper(context);
            var repo   = new Repository(context, mapper);

            BusinessLogic.Creator c = new BusinessLogic.Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            };

            //act
            await repo.AddCreatorAsync(c);

            try
            {
                await repo.AddChannelAsync(c, "MatheMartian");

                await repo.UpdateChannelNameAsync("MatheMartian", c);

                //assert
                Assert.True(false);
            }
            catch
            {
                Assert.True(true);
            }
        }
Пример #4
0
        public async Task AddCreatorsShouldAddCreatorsAsync()
        {
            //arrange
            var options = new DbContextOptionsBuilder <YouTubeJamContext>()
                          .UseInMemoryDatabase("AddCreatorsShouldAdd")
                          .Options;

            using var context = new YouTubeJamContext(options);
            var mapper = new DBMapper(context);
            var repo   = new Repository(context, mapper);

            BusinessLogic.Creator c = new BusinessLogic.Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            };

            //act
            await repo.AddCreatorAsync(c);

            //assert
            using var assertContext = new YouTubeJamContext(options);
            var rest = assertContext.Creator.Select(c => c);

            Assert.NotNull(rest);
        }
Пример #5
0
        public async Task LogInShouldLogInAsync()
        {
            //assert
            var options = new DbContextOptionsBuilder <YouTubeJamContext>()
                          .UseInMemoryDatabase("LogInShouldLogIn")
                          .Options;

            using var context = new YouTubeJamContext(options);
            var mapper = new DBMapper(context);
            var repo   = new Repository(context, mapper);

            string email = "*****@*****.**";

            BusinessLogic.Creator c = new BusinessLogic.Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = email
            };

            //act
            await repo.AddCreatorAsync(c);

            await repo.AddChannelAsync(c, "Amrs");

            //assert
            using var assertContext = new YouTubeJamContext(options);
            mapper = new DBMapper(assertContext);
            repo   = new Repository(assertContext, mapper);
            var result = await repo.LogInAsync(email);

            Assert.NotNull(result);
        }
Пример #6
0
        public async Task LogInShouldHandleExceptionsAsync()
        {
            //assert
            var options = new DbContextOptionsBuilder <YouTubeJamContext>()
                          .UseInMemoryDatabase("LogInShouldHandleExceptions")
                          .Options;


            string email = "*****@*****.**";


            using var assertContext = new YouTubeJamContext(options);
            var mapper = new DBMapper(assertContext);
            var repo   = new Repository(assertContext, mapper);

            //act & assert
            try
            {
                var result = await repo.LogInAsync(email);

                Assert.True(false);
            }
            catch (Persistence.CreatorDoesNotExistException)
            {
                Assert.True(true);
            }
        }
Пример #7
0
        public async Task UpdateChannelNameShouldUpdateAsync()
        {
            //arrange
            var options = new DbContextOptionsBuilder <YouTubeJamContext>()
                          .UseInMemoryDatabase("UpdateChannelNameShouldUpdate")
                          .Options;

            using var context = new YouTubeJamContext(options);
            var mapper = new DBMapper(context);
            var repo   = new Repository(context, mapper);

            BusinessLogic.Creator c = new BusinessLogic.Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            };

            //act
            await repo.AddCreatorAsync(c);

            await repo.AddChannelAsync(c, "MatheMartian");

            await repo.UpdateChannelNameAsync("MathMars", c);

            //assert
            using var assertContext = new YouTubeJamContext(options);
            mapper = new DBMapper(assertContext);
            repo   = new Repository(assertContext, mapper);
            var result = await repo.GetUserAsync("*****@*****.**");

            Assert.True(result.ChannelName == "MathMars");
        }
Пример #8
0
        public async Task AddCreatorandChannelShouldAddAsync()
        {
            //arrange
            var options = new DbContextOptionsBuilder <YouTubeJamContext>()
                          .UseInMemoryDatabase("AddCreatorandChannelShouldAdd")
                          .Options;

            using var context = new YouTubeJamContext(options);
            var mapper = new DBMapper(context);
            var repo   = new Repository(context, mapper);

            BusinessLogic.Creator c = new BusinessLogic.Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            };
            string channelName = "MatheMartian";
            //act
            await repo.AddCreatorandChannelAsync(c, channelName);

            //assert
            using var assertContext = new YouTubeJamContext(options);
            var result = assertContext.Channel.FirstOrDefaultAsync(c => c.ChannelName == channelName);

            Assert.NotNull(result);
        }
Пример #9
0
        public async Task AddCreatorandChannelShouldBeUniqueAsync()
        {
            //arrange
            var options = new DbContextOptionsBuilder <YouTubeJamContext>()
                          .UseInMemoryDatabase("AddCreatorandChannelShouldBeUnique")
                          .Options;

            using var context = new YouTubeJamContext(options);
            var mapper = new DBMapper(context);
            var repo   = new Repository(context, mapper);

            BusinessLogic.Creator c = new BusinessLogic.Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            };
            string channelName = "MatheMartian";

            //act
            try
            {
                await repo.AddCreatorandChannelAsync(c, channelName);

                await repo.AddCreatorandChannelAsync(c, channelName);

                Assert.True(false);
            }
            catch (ChannelNameTakenException)
            {
                Assert.True(true);
            }
        }
Пример #10
0
    // Use this for initialization
    void Start()
    {
        SqliteInit.InitSqlite();


        FieldLister lister = new FieldLister();

        UserData[] data = new UserData[2];

        data[0]                  = new UserData();
        data[0].ID               = 1;
        data[0].Name             = "Tarou";
        data[0].Hoge             = "fuga";
        data[0].Age              = 32;
        data[0].LastUpdated      = new DateTime(2013, 4, 1);
        data[0].NestedClass.Fuga = "bbbb";
        data[0].NestedClass.Hoge = 23;

        data[1]             = new UserData();
        data[1].ID          = 2;
        data[1].Name        = "Jirou";
        data[1].Hoge        = "wahoo";
        data[1].Age         = 11;
        data[1].AddressData = "aaaaa";
        data[1].LastUpdated = new DateTime(2013, 5, 1);

        Write(data[0].ToString());


        var info = lister.ListUp <UserData>();

        Write(info.ToString());

        var    sqlMaker = new SQLMaker();
        string insert   = sqlMaker.GenerateInsertSQL(info, data[0]);
        string update   = sqlMaker.GenerateUpdateSQL(info, data[0]);

        Write("Insert = {0}", insert);
        Write("Update = {0}", update);

        DBMapper mapper = new DBMapper(SqliteInit.Evolution.Database);

        mapper.UpdateOrInsertAll(data);

        UserData[] fromDb = mapper.Read <UserData>("SELECT * FROM UserData;");
        Write(fromDb[0].ToString());
        Write(fromDb[1].ToString());


        JSONMapper jsonMapper = new JSONMapper();

        string json = jsonMapper.Write <UserData>(fromDb);

        UserData[] fromJson = jsonMapper.Read <UserData>(json);

        Write("Json = {0}", json);

        Write(fromJson[0].ToString());
        Write(fromJson[1].ToString());
    }
Пример #11
0
        public async Task AddVideoShouldAddVideoAsync()
        {
            //arrange
            var options = new DbContextOptionsBuilder <YouTubeJamContext>()
                          .UseInMemoryDatabase("AddVideoShouldAdd")
                          .Options;

            using var context = new YouTubeJamContext(options);
            var mapper = new DBMapper(context);
            var repo   = new Repository(context, mapper);

            BusinessLogic.Creator c = new BusinessLogic.Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            };
            var    url         = "abc";
            string channelName = "MatheMartian";

            //act
            await repo.AddCreatorAsync(c);

            await repo.AddChannelAsync(c, channelName);

            await repo.AddVideoAsync(url, channelName);

            //assert
            using var assertContext = new YouTubeJamContext(options);
            var rest = await assertContext.Video.FirstAsync(v => v.URL == url);

            Assert.NotNull(rest);
        }
Пример #12
0
    // Use this for initialization
    void Start()
    {
        SqliteInit.InitSqlite();

        FieldLister lister = new FieldLister();

        UserData[] data = new UserData[2];

        data[0] = new UserData();
        data[0].ID = 1;
        data[0].Name = "Tarou";
        data[0].Hoge = "fuga";
        data[0].Age = 32;
        data[0].LastUpdated = new DateTime(2013,4,1);
        data[0].NestedClass.Fuga = "bbbb";
        data[0].NestedClass.Hoge = 23;

        data[1] = new UserData();
        data[1].ID = 2;
        data[1].Name = "Jirou";
        data[1].Hoge = "wahoo";
        data[1].Age = 11;
        data[1].AddressData = "aaaaa";
        data[1].LastUpdated = new DateTime(2013,5,1);

        Debug.Log(data[0]);

        var info = lister.ListUp<UserData>();

        Debug.Log(info);

        var sqlMaker = new SQLMaker();
        string insert = sqlMaker.GenerateInsertSQL(info,data[0]);
        string update = sqlMaker.GenerateUpdateSQL(info,data[0]);

        Debug.Log("Insert = " + insert);
        Debug.Log("Update = " + update);

        DBMapper mapper = new DBMapper(SqliteInit.Evolution.Database);

        mapper.UpdateOrInsertAll(data);

        UserData[] fromDb = mapper.Read<UserData>("SELECT * FROM UserData;");
        Debug.Log(fromDb[0]);
        Debug.Log(fromDb[1]);

        JSONMapper jsonMapper = new JSONMapper();

        string json = jsonMapper.Write<UserData>(fromDb);
        UserData[] fromJson = jsonMapper.Read<UserData>(json);

        Debug.Log("Json = " + json);

        Debug.Log(fromJson[0]);
        Debug.Log(fromJson[1]);
    }
Пример #13
0
 public OrderHistoryMenu(SavvyContext context, DBMapper mapper)
 {
     this.repo          = new SavvyRepo(context, mapper);
     this.locationtask  = new LocationTask(repo);
     this.inventorytask = new InventoryTask(repo);
     this.producttask   = new ProductTask(repo);
     this.ordertask     = new OrderTask(repo);
     this.orderitemtask = new OrderItemTask(repo);
     this.customertask  = new CustomerTask(repo);
 }
Пример #14
0
        static void Main(string[] args)
        {
            SavvyContext context = new SavvyContext();
            DBMapper     mapper  = new DBMapper();

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.File("Logs\\Logtxt.txt")
                         .CreateLogger();
            MainMenu mainMenu = new MainMenu(context, mapper);

            mainMenu.start();
        }
Пример #15
0
        public List <int> getUsers(DateTime dt)
        {
            DBMapper dm = new DBMapper();

            ListDictionary Params = new ListDictionary();

            Params.Add("@dt", dt);

            DataSet ds = dm.BLAddOrUpdateScreeningsKings();

            return(new List <int>());
        }
Пример #16
0
        public CartMenu()
        {
            SavvyContext context = new SavvyContext();
            DBMapper     mapper  = new DBMapper();

            this.repo          = new SavvyRepo(context, mapper);
            this.locationtask  = new LocationTask(repo);
            this.inventorytask = new InventoryTask(repo);
            this.producttask   = new ProductTask(repo);
            this.carttask      = new CartTask(repo);
            this.cartitemtask  = new CartItemTask(repo);
            this.ordertask     = new OrderTask(repo);
            this.orderitemtask = new OrderItemTask(repo);
        }
Пример #17
0
        public async Task AddAnalysisShouldNotCreateNewCreatorsAsync()
        {
            //arrange
            var options = new DbContextOptionsBuilder <YouTubeJamContext>()
                          .UseInMemoryDatabase("AddAnalysisShouldNotCreateNewCreators")
                          .Options;

            using var context = new YouTubeJamContext(options);
            var mapper = new DBMapper(context);
            var repo   = new Repository(context, mapper);

            BusinessLogic.Creator c = new BusinessLogic.Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            };

            AverageSentiment avg = new AverageSentiment()
            {
                VideoURL = "Abc",
                AverageSentimentScore = 0.5
            };

            //act
            await repo.AddCreatorAsync(c);

            await repo.AddChannelAsync(c, "MatheMartian");

            await repo.AddVideoAsync("Abc", "MatheMartian");

            await repo.AddAnalysisAsync(avg, c);

            //assert
            using var assertContext = new YouTubeJamContext(options);
            mapper = new DBMapper(assertContext);
            repo   = new Repository(assertContext, mapper);
            var result = await repo.GetCreatorsAsync();

            if (result.Count > 1)
            {
                Assert.True(false);
            }
            else
            {
                Assert.True(true);
            }
        }
    // Use this for initialization
    void Start()
    {
                #if UNITY_ANDROID
        MyLibs.InitializeSQLCipher();
                #endif

        if (dataObjects.Length < 1)
        {
            Write("No data to write database!");
            return;
        }

        ORMSQLiteInit.InitSqlite(dbFile, dbDirectory, password);
        Write("Open Database at " + ORMSQLiteInit.pathDB);

        FieldLister lister = new FieldLister();

        Write(dataObjects[0].ToString());
        var info = lister.ListUp <UserData>();

        Write(info.ToString());
        string insert = SQLMaker.GenerateInsertSQL(info, dataObjects[0]);
        string update = SQLMaker.GenerateUpdateSQL(info, dataObjects[0]);

        Write("Insert = {0}", insert);
        Write("Update = {0}", update);

        DBMapper mapper = new DBMapper(ORMSQLiteInit.Evolution.Database);
        mapper.UpdateOrInsertAll(dataObjects);

        UserData[] fromDb = mapper.Read <UserData>("SELECT * FROM UserData;");
        Write(fromDb[0].ToString());
        Write(fromDb[1].ToString());

        JSONMapper jsonMapper = new JSONMapper();
        string     json       = jsonMapper.Write <UserData>(fromDb);
        UserData[] fromJson   = jsonMapper.Read <UserData>(json);

        Write("Json = {0}", json);
        Write(fromJson[0].ToString());
        Write(fromJson[1].ToString());

                #if UNITY_ANDROID
        MyLibs.ToastMessage("SQLCipher Done");
                #endif
    }
Пример #19
0
        public async Task AddAnalysisAsyncWithLimitedInfoShouldAddAsync()
        {
            //arrange
            var options = new DbContextOptionsBuilder <YouTubeJamContext>()
                          .UseInMemoryDatabase("AddAnalysisAsyncWithLimitedInfoShouldAddAsync")
                          .Options;

            using var context = new YouTubeJamContext(options);
            var mapper = new DBMapper(context);
            var repo   = new Repository(context, mapper);

            BusinessLogic.Creator c = new BusinessLogic.Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            };
            BusinessLogic.Creator b = new BusinessLogic.Creator()
            {
                Email       = "*****@*****.**",
                ChannelName = "Mathemartian"
            };
            AverageSentiment avg = new AverageSentiment()
            {
                VideoURL = "Abc",
                AverageSentimentScore = 0.5
            };

            //act
            await repo.AddCreatorAsync(c);

            await repo.AddChannelAsync(c, "MatheMartian");

            await repo.AddAnalysisAsync(avg, b);

            //assert
            using var assertContext = new YouTubeJamContext(options);
            var rest = await assertContext.Analysis1.FirstAsync();

            Assert.NotNull(rest);
        }
Пример #20
0
        public async Task GetUserHistoryShouldGetSomethingAsync()
        {
            //arrange
            var options = new DbContextOptionsBuilder <YouTubeJamContext>()
                          .UseInMemoryDatabase("GetUserHistoryShouldGetSomething")
                          .Options;

            using var context = new YouTubeJamContext(options);
            var mapper = new DBMapper(context);
            var repo   = new Repository(context, mapper);

            BusinessLogic.Creator c = new BusinessLogic.Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            };

            AverageSentiment avg = new AverageSentiment()
            {
                VideoURL = "Abc",
                AverageSentimentScore = 0.5
            };

            //act
            await repo.AddCreatorAsync(c);

            await repo.AddChannelAsync(c, "MatheMartian");

            await repo.AddVideoAsync("Abc", "MatheMartian");

            await repo.AddAnalysisAsync(avg, c);

            //assert
            using var assertContext = new YouTubeJamContext(options);
            mapper = new DBMapper(assertContext);
            repo   = new Repository(assertContext, mapper);
            var result = await repo.GetUserSearchHistoryAsync("*****@*****.**");

            Assert.NotNull(result[0].VideoURL);
        }
        /// <summary>
        /// Validates Authentication
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public bool ValidateAuthentication(HttpRequestMessage request)
        {
            bool accepted = true;
            HttpRequestHeaders headers = request.Headers;

            if (!headers.Contains("x-tdws-authid"))
            {
                return(false);
            }
            SimpleAES decryptText = new SimpleAES("V&WWJ3d39brdR5yUh5(JQGHbi:FB@$^@", "W4aRWS!D$kgD8Xz@");
            string    strDecrypt  = decryptText.DecryptString(headers.GetValues("x-tdws-authid").First());

            DBMapper dbMapper = new DBMapper();

            if (!dbMapper.ValidateDevice(Guid.Parse(strDecrypt)))
            {
                return(false);
            }

            accepted = ValidateAuthenticationBase(request);

            return(accepted);
        }
Пример #22
0
 public ReadExcelData()
 {
     dbMapper = new DBMapper();
 }
Пример #23
0
 public MainMenu(SavvyContext context, DBMapper mapper)
 {
     this.customerMenu = new CustomerMenu(context, mapper);
     this.managerMenu  = new ManagerMenu(new SavvyRepo(context, mapper));
 }
Пример #24
0
 public HomeRepo()
 {
     this.context = new HomeContext();
     this.mapper  = new DBMapper();
 }
Пример #25
0
 public ProductMenu(SavvyContext context, DBMapper mapper, Customer Customer)
 {
     this.repo     = new SavvyRepo(context, mapper);
     this.Customer = Customer;
 }
Пример #26
0
        public void InsertError(ApplicationLog appLog)
        {
            DBMapper dataMapper = new DBMapper();

            dataMapper.InsertError(appLog);
        }