Ejemplo n.º 1
0
        public void AddLogTest()
        {
            DataLayer dl     = new DataLayer();
            string    app_id = "test app " + new Random().Next(100, 500).ToString();
            var       app    = dl.AddApplication(new application
            {
                application_id = app_id,
                display_name   = "Test application",
                secret         = Guid.NewGuid().ToString().Replace("-", string.Empty)
            });
            var id = dl.AddLog(new log
            {
                application_id = app.application_id,
                level          = "Info",
                logger         = "LogApi.App_Code.Tests.AddLogTest",
                message        = "Test of database layer"
            });

            using (var ctx = new CrossoverDataContext())
            {
                var logItem = ctx.logs.FirstOrDefault(x => x.log_id == id);
                Assert.IsTrue(logItem.log_id == id);
                ctx.logs.DeleteOnSubmit(logItem);
                ctx.applications.DeleteOnSubmit(ctx.applications.FirstOrDefault(x => x.application_id == app_id));
                ctx.SubmitChanges();
            }
        }
Ejemplo n.º 2
0
        public void AddApplicationTest()
        {
            DataLayer dl     = new DataLayer();
            string    app_id = "test app " + new Random().Next(100, 500).ToString();
            var       app    = dl.AddApplication(new application
            {
                application_id = app_id,
                display_name   = "Test application",
                secret         = Guid.NewGuid().ToString().Replace("-", string.Empty)
            });
            var dbApp = dl.GetAppByNameAndSecret(app.application_id, app.secret);

            Assert.IsTrue(dbApp.application_id == app_id);
            using (var ctx = new CrossoverDataContext())
            {
                ctx.applications.DeleteOnSubmit(ctx.applications.FirstOrDefault(x => x.application_id == app_id));
                ctx.SubmitChanges();
            }
        }
Ejemplo n.º 3
0
        public void IndexTest()
        {
            Assert.IsTrue(Task.Run(async() =>
            {
                using (var ctx = new CrossoverDataContext())
                {
                    var app         = ctx.applications.FirstOrDefault();
                    string app_name = "test_app_" + new Random().Next(100, 500).ToString();

                    var result = await new RegisterController().Index(new AppRegistration
                    {
                        display_name = app_name
                    }) as OkNegotiatedContentResult <RegisterAppResult>;

                    var savedApp = ctx.applications.FirstOrDefault(x => x.display_name == app_name);
                    var saved    = savedApp != null;

                    ctx.applications.DeleteOnSubmit(savedApp);
                    ctx.SubmitChanges();

                    return(saved);
                }
            }).GetAwaiter().GetResult());
        }