public void ReturnsCanvasUserIsAddedAsGroup() { var canvas = Presto.Persist <Canvas>(); ClarityDB.CurrentTenant = canvas.Tenant; ClarityDB.CurrentTenant.Canvases.Add(canvas); var group = CreateGroup(canvas.Tenant); canvas.MenuTile.Members.Add(new Membership { Group = group, GroupID = group.ID }); var user = CreateUser(canvas.Tenant); group.Users.Add(user); try { ClarityDB.Instance.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { throw ex; } ClarityDB.CreateInstance(user); Assert.AreEqual(1, ClarityDB.Instance.Canvases.Count()); }
public void CategoryIsValid_ReturnsOK() { NumericCategory category = Presto.Persist <NumericCategory>(); var json = category.ToJson(); var result = service.UpdateCategory(category.ID, json); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); }
public void CategoryIsValid_ReturnsJson() { NumericCategory category = Presto.Persist <NumericCategory>(); var json = category.ToJson(); var result = service.UpdateCategory(category.ID, json); Assert.NotNull(result.Json); }
public void CategoryIsNotValid_ReturnsBadRequest() { NumericCategory category = Presto.Persist <NumericCategory>(X => X.ID = 1); var json = JObject.Parse("{ id: 1 }"); var result = service.UpdateCategory(1, json); Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode); }
public void CategoryIsValid_SavesChanges() { NumericCategory category = Presto.Persist <NumericCategory>(); var json = category.ToJson(); var result = service.UpdateCategory(category.ID, json); Assert.IsTrue(fakeDB.SaveChangesCalled); }
public void Setup() { fakeDB = new FakeDB(); ClarityDB.Instance = fakeDB; ClarityDB.CurrentTenant = Presto.Persist <Tenant>(); service = new CategoryService(); }
public void SetUp() { HttpContext.Current = new HttpContext( new HttpRequest(null, "http://localhost:9090/", null), new HttpResponse(null)); ClarityDB.Instance = new FakeDB(); user = Presto.Persist <User>(); }
public void ReturnsOwnScorecard() { var scorecard = Presto.Persist <Scorecard>(); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(scorecard.MenuTile.Owner); Assert.AreEqual(1, ClarityDB.Instance.Scorecards.Count()); }
public void GetCategories_VariableDoesNotExist_ReturnsEmpty() { ClarityDB.Instance = new FakeDB(); var variable = Presto.Persist <NumericVariable>(); var service = new CategoryService(); RestApiResult result = service.GetCategoriesByVariable(variable.ID); Assert.AreEqual(0, result.Json.Count()); }
public void ReturnsOwnMenu() { var menuTile = Presto.Persist <MenuTile>(); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(menuTile.Owner); Assert.AreEqual(1, ClarityDB.Instance.MenuTiles.Count()); }
public void GetCategories_VariableHasOneCategory_ReturnsOneCategorie() { ClarityDB.Instance = new FakeDB(); var category = Presto.Persist <NumericCategory>(); var service = new CategoryService(); RestApiResult result = service.GetCategoriesByVariable(category.VariableID); Assert.AreEqual(1, result.Json.Count()); }
public void GetCategoriesByVariable_VariableExists_ReturnsOK() { ClarityDB.Instance = new FakeDB(); var variable = Presto.Persist <NumericVariable>(); var service = new CategoryService(); RestApiResult result = service.GetCategoriesByVariable(variable.ID); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); }
public void SetUp() { fakeDB = new FakeDB(); ClarityDB.Instance = fakeDB; Presto.Persist <User>(x => x.UserName = "******"); user = Presto.Persist <User>(x => x.UserName = "******"); fakeFormsAuthentication = new FakeFormsAuthentication(); service = new AuthenticationService(fakeFormsAuthentication, new FakePasswordHash(), null); }
public void FiltersOtherPersonScorecardSection() { var section = Presto.Persist <ScorecardSection>(); var user = CreateUser(section.Scorecard.Tenant); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(user); Assert.AreEqual(0, ClarityDB.Instance.ScorecardSections.Count()); }
public void FiltersOtherPersonMenuTile() { var menuTile = Presto.Persist <MenuTile>(); var user = CreateUser(menuTile.Tenant); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(user); Assert.AreEqual(0, ClarityDB.Instance.MenuTiles.Count()); }
public void GetCategories_VariableHasOneCategory_ReturnsCorrectCategory() { ClarityDB.Instance = new FakeDB(); var category = Presto.Persist <NumericCategory>(); var service = new CategoryService(); RestApiResult result = service.GetCategoriesByVariable(category.VariableID); var json = result.Json.First(); Assert.AreEqual(category.ID, json.Value <long>("id")); Assert.AreEqual(category.Label, json.Value <string>("label")); }
public void ReturnsOwnCanvas() { var canvas = Presto.Persist <Canvas>(); ClarityDB.CurrentTenant = canvas.Tenant; ClarityDB.CurrentTenant.Canvases.Add(canvas); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(canvas.MenuTile.Owner); Assert.AreEqual(1, ClarityDB.Instance.Canvases.Count()); }
public void FiltersOtherPersonCanvas() { var canvas = Presto.Persist <Canvas>(); var user = CreateUser(canvas.Tenant); ClarityDB.CurrentTenant = canvas.Tenant; ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(user); Assert.AreEqual(0, ClarityDB.Instance.Canvases.Count()); }
public void GetCategories_VariableHasManyCategories_ReturnsCollectionSortedByLabel() { ClarityDB.Instance = new FakeDB(); var category1 = Presto.Persist <NumericCategory>(x => { x.NumericValue = 0; x.Label = "Male"; }); var category2 = Presto.Persist <NumericCategory>(x => { x.NumericValue = 1; x.Label = "Female"; x.Variable = category1.Variable; x.Variable.Categories.Add(x); }); var service = new CategoryService(); RestApiResult result = service.GetCategoriesByVariable(category1.VariableID); Assert.AreEqual(category2.Label, result.Json.First().Value <string>("label")); Assert.AreEqual(category1.Label, result.Json.ElementAt(1).Value <string>("label")); }
public void FiltersOtherPersonCanvasPage() { var page = Presto.Persist <Page>(); var user = CreateUser(page.Canvas.Tenant); ClarityDB.CurrentTenant = page.Canvas.Tenant; ClarityDB.CurrentTenant.Canvases.Add(page.Canvas); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(user); Assert.AreEqual(0, ClarityDB.Instance.Pages.Count()); }
public override void SetUp() { base.SetUp(); var user = Presto.Persist <User>(); firstTenant = user.Tenant; secondTenant = Presto.Persist <Tenant>(); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(user); }
public void ReturnsOwnCanvasFigures() { var figure = Presto.Persist <Figure>(); ClarityDB.CurrentTenant = figure.Page.Canvas.Tenant; ClarityDB.CurrentTenant.Canvases.Add(figure.Page.Canvas); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(figure.Page.Canvas.MenuTile.Owner); ClarityDB.Instance.SaveChanges(); Assert.AreEqual(1, ClarityDB.Instance.Figures.Count()); }
public override void SetUp() { base.SetUp(); firstFigure = Presto.Persist <Figure>(); firstTenant = firstFigure.Page.Canvas.Tenant; secondFigure = Presto.Persist <Figure>(); secondTenant = secondFigure.Page.Canvas.Tenant; ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(firstTenant.Users.First()); }
public override void SetUp() { base.SetUp(); firstMenuTile = Presto.Persist <MenuTile>(x => x.Title = "First"); firstTenant = firstMenuTile.Tenant; secondMenuTile = Presto.Persist <MenuTile>(x => x.Title = "Second"); secondTenant = secondMenuTile.Tenant; ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(firstMenuTile.Owner); }
public override void SetUp() { base.SetUp(); firstOpenAnswerDashboard = Presto.Persist <OpenAnswerDashboard>(); firstTenant = firstOpenAnswerDashboard.Tenant; secondOpenAnswerDashboard = Presto.Persist <OpenAnswerDashboard>(); secondTenant = secondOpenAnswerDashboard.Tenant; ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(firstTenant.Users.First()); }
public override void SetUp() { base.SetUp(); firstScorecardSection = Presto.Persist <ScorecardSection>(); firstTenant = firstScorecardSection.Scorecard.Tenant; secondScorecardSection = Presto.Persist <ScorecardSection>(); secondTenant = secondScorecardSection.Scorecard.Tenant; ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(firstTenant.Users.First()); }
public void ReturnsMenuTileUserIsAddedAsUser() { var menuTile = Presto.Persist <MenuTile>(); var user = CreateUser(menuTile.Tenant); menuTile.Members.Add(new Membership { User = user, UserID = user.ID }); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(user); Assert.AreEqual(1, ClarityDB.Instance.MenuTiles.Count()); }
public void ReturnsScorecardUserIsAddedAsUser() { var scorecard = Presto.Persist <Scorecard>(); var user = CreateUser(scorecard.Tenant); scorecard.MenuTile.Members.Add(new Membership { User = user, UserID = user.ID }); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(user); Assert.AreEqual(1, ClarityDB.Instance.Scorecards.Count()); }
public override void SetUp() { base.SetUp(); firstDataBatch = Presto.Persist <DataBatch>(); firstTenant = firstDataBatch.Tenant; secondDataBatch = Presto.Persist <DataBatch>(); secondTenant = secondDataBatch.Tenant; ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(firstDataBatch.UploadedBy); }
public override void SetUp() { base.SetUp(); firstOption = Presto.Persist <Option>(); secondOption = Presto.Persist <Option>(); var user = Presto.Create <User>(); user.Tenant = firstOption.Tenant; user.TenantID = firstOption.TenantID; firstOption.Tenant.Users.Add(user); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(user); }