public void CategoryDoesNotExist_ReturnsNotFound() { NumericCategory category = Presto.Create <NumericCategory>(); var result = service.UpdateCategory(category.ID, category.ToJson()); Assert.AreEqual(HttpStatusCode.NotFound, result.StatusCode); }
public void VariableIsNull_ReturnsNotFound() { NumericCategory category = Presto.Create <NumericCategory>(); var result = service.Create(category.ToJson()); Assert.AreEqual(HttpStatusCode.NotFound, result.StatusCode); }
public void CannotAddPageOfAnotherTenant() { var canvas = secondTenant.Canvases.First(); var page = Presto.Create <Page>(x => { x.Canvas = canvas; x.CanvasID = canvas.ID; }); Assert.Throws <ArgumentOutOfRangeException>(() => ClarityDB.Instance.Pages.Add(page)); }
public void ToJson_HomeMenuIDIsNull_ReturnsJObjectWithEmptyHomeMenu() { var user = Presto.Create <User>(x => { x.HomeMenuID = null; }); var jObject = user.ToJson(); var homeMenuID = jObject.Value <string>("homeMenuId"); Assert.AreEqual("", homeMenuID); }
public void Add_User() { var user = Presto.Create <User>(); ClarityDB.Instance.Users.Add(user); ClarityDB.Instance.SaveChanges(); Assert.That(DatabaseHelper.TableHasRows("Users")); }
public void CannotAddAssociatedVariableOfAnotherTenant() { var associatedVariable = Presto.Create <AssociatedVariable>(x => { x.VariableGroup = secondTenant.Datasets.First().VariableGroups.First(); x.VariableGroupID = x.VariableGroup.ID; }); Assert.Throws <ArgumentOutOfRangeException>(() => ClarityDB.Instance.AssociatedVariables.Add(associatedVariable)); }
private static Group CreateGroup(Tenant tenant) { var group = Presto.Create <Group>(); group.TenantID = tenant.ID; group.Tenant = tenant; ClarityDB.Instance.Groups.Add(group); return(group); }
private static User CreateUser(Tenant tenant) { var user = Presto.Create <User>(); user.Tenant = tenant; user.TenantID = tenant.ID; ClarityDB.Instance.Users.Add(user); return(user); }
public void CannotAddCategoryOfAnotherTenant() { var category = Presto.Create <NumericCategory>(x => { x.Variable = secondTenant.Datasets.First().Variables.First(); x.VariableID = x.Variable.ID; }); Assert.Throws <ArgumentOutOfRangeException>(() => ClarityDB.Instance.Categories.Add(category)); }
public void SetUp() { user = Presto.Create <User>(x => { x.ID = 10; x.Role = Role.PartnerAccount; x.UserName = "******"; x.LastName = "Pan"; x.FirstName = "Peter"; }); json = user.ToJson(); }
public void Add_EntityMatchesFilter_AddsEntityToCollection() { var user = Presto.Create <User>(x => { x.UserName = "******"; x.TenantID = firstTenant.ID; x.Tenant = firstTenant; }); var actual = users.Add(user); ClarityDB.Instance.SaveChanges(); Assert.AreSame(user, actual); Assert.AreEqual(2, users.Count()); }
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); }
public override void SetUp() { base.SetUp(); firstTenant = Presto.Persist <Tenant>(); firstUser = Presto.Create <User>(); firstTenant.Users.Add(firstUser); secondTenant = Presto.Persist <Tenant>(); secondUser = Presto.Create <User>(); secondTenant.Users.Add(secondUser); ClarityDB.Instance.SaveChanges(); filter = x => x.TenantID == firstTenant.ID; users = new FilteredDbSet <User>((ClarityDB)ClarityDB.Instance, filter); }
public override void SetUp() { base.SetUp(); var user = Presto.Persist <User>(); firstTenant = user.Tenant; firstAssociatedVariable = Presto.Create <AssociatedVariable>(); firstTenant.Datasets.Add(firstAssociatedVariable.VariableGroup.Dataset); secondTenant = Presto.Persist <Tenant>(); secondAssociatedVariable = Presto.Create <AssociatedVariable>(); secondTenant.Datasets.Add(secondAssociatedVariable.VariableGroup.Dataset); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(user); }
public override void SetUp() { base.SetUp(); var user = Presto.Persist <User>(); firstTenant = user.Tenant; firstImage = Presto.Create <Image>(); firstTenant.Images.Add(firstImage); secondTenant = Presto.Persist <Tenant>(); secondImage = Presto.Create <Image>(); secondTenant.Images.Add(secondImage); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(user); }
public override void SetUp() { base.SetUp(); var user = Presto.Persist <User>(); firstTenant = user.Tenant; firstCategory = Presto.Create <NumericCategory>(); firstTenant.Datasets.Add(firstCategory.Variable.Dataset); secondTenant = Presto.Persist <Tenant>(); secondCategory = Presto.Create <NumericCategory>(); secondTenant.Datasets.Add(secondCategory.Variable.Dataset); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(user); }
public override void SetUp() { base.SetUp(); var user = Presto.Persist <User>(); firstTenant = user.Tenant; firstDashboardWizard = Presto.Create <DashboardWizard>(x => { x.TenantID = firstTenant.ID; x.Tenant = firstTenant; }); ClarityDB.Instance.DashboardWizards.Add(firstDashboardWizard); secondTenant = Presto.Persist <Tenant>(); secondDashboardWizard = Presto.Create <DashboardWizard>(x => { x.TenantID = secondTenant.ID; x.Tenant = secondTenant; }); ClarityDB.Instance.DashboardWizards.Add(secondDashboardWizard); ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(user); }
public void KeyFigure_CannotAddFigureOfAnotherTenant() { base.SetUp(); var firstMenuTile = Presto.Persist <MenuTile>(); firstTenant = firstMenuTile.Tenant; var secondMenuTile = Presto.Persist <MenuTile>(); secondTenant = secondMenuTile.Tenant; ClarityDB.Instance.SaveChanges(); ClarityDB.CreateInstance(firstTenant.Users.First()); var figure = Presto.Create <Figure>(x => { x.PageID = null; x.Page = null; x.MenuTile = secondMenuTile; x.MenuTileID = x.MenuTile.ID; }); Assert.Throws <ArgumentOutOfRangeException>(() => ClarityDB.Instance.Figures.Add(figure)); }
public void SetUp() { updatedUser = new User { ID = 10, FirstName = "New First Name", LastName = "New Last Name", Email = "*****@*****.**", UserName = "******", Password = "******", Role = Role.AccountOwner, HomeMenuID = 10, UseAccountNameAsHomeMenu = true, Disabled = true }; json = updatedUser.ToJson(); user = Presto.Create <User>(); }
public void CannotAddFilterOfAnotherTenant() { var filter = Presto.Create <Filter>(x => { x.MenuTile = secondTenant.MenuTiles.First(); x.MenuTileID = x.MenuTile.ID; }); Assert.Throws <ArgumentOutOfRangeException>(() => ClarityDB.Instance.Filters.Add(filter)); }
public void CannotAddOpenAnswerDashboardOfAnotherTenant() { var canvas = Presto.Create <OpenAnswerDashboard>(x => { x.Tenant = secondTenant; x.TenantID = x.Tenant.ID; }); Assert.Throws <ArgumentOutOfRangeException>(() => ClarityDB.Instance.OpenAnswerDashboards.Add(canvas)); }
public void SetUp() { user = Presto.Create <User>(); }
public void Validate_DefaultFactory_Passes() { var user = Presto.Create <User>(); Assert.IsTrue(user.IsValid()); }
public void Validate_WithoutLastName_Passes() { var user = Presto.Create <User>(x => x.LastName = ""); Assert.IsTrue(user.IsValid()); }
public void Validate_WithoutEmail_Fails() { var user = Presto.Create <User>(x => x.Email = ""); Assert.That(user.IsInvalid()); }
public void Validate_IncorrectEmailFormat_Fails(string email) { var user = Presto.Create <User>(x => x.Email = email); Assert.That(user.IsInvalid()); }
public void Validate_CorrectEmailFormat_Passes(string email) { var user = Presto.Create <User>(x => x.Email = email); Assert.That(user.IsValid()); }
public void CannotAddMoreTenant() { var tenant = Presto.Create <Tenant>(); Assert.Throws <ArgumentOutOfRangeException>(() => ClarityDB.Instance.Tenants.Add(tenant)); }
public void CannotAddDashboardWizardOfAnotherTenant() { var wizard = Presto.Create <DashboardWizard>(x => { x.Tenant = secondTenant; x.TenantID = secondTenant.ID; }); Assert.Throws <ArgumentOutOfRangeException>(() => ClarityDB.Instance.DashboardWizards.Add(wizard)); }
public void CannotAddImageOfAnotherTenant() { var image = Presto.Create <Image>(x => { x.TenantID = secondTenant.ID; x.Tenant = secondTenant; }); Assert.Throws <ArgumentOutOfRangeException>(() => ClarityDB.Instance.Images.Add(image)); }