public async Task CreateDashboard() { var insertedValues = new Dictionary <string, object> { { "Title", "Inserted title" }, { "OwnerTypeId", 2 }, { "DashboardConfig", "Inserted Dash Config" } }; var response1 = await Controller.CreateDashboard(new Dashboard { Title = insertedValues["Title"] as string, OwnerTypeId = (int)insertedValues["OwnerTypeId"], DashboardConfig = insertedValues["DashboardConfig"] as string }); var result1 = CustomAssert.AssertCreatedAtResponse(response1); Assert.AreEqual(result1.Title, insertedValues["Title"] as string); Assert.AreEqual(result1.OwnerTypeId, (int)insertedValues["OwnerTypeId"]); Assert.AreEqual(result1.DashboardConfig, insertedValues["DashboardConfig"] as string); // ReSharper disable once PossibleInvalidOperationException var response2 = await Controller.GetDashboard(result1.Id.Value); var result2 = CustomAssert.AssertOkResponse(response2); Assert.AreEqual(result2.Title, insertedValues["Title"] as string); Assert.AreEqual(result2.OwnerTypeId, (int)insertedValues["OwnerTypeId"]); Assert.AreEqual(result2.DashboardConfig, insertedValues["DashboardConfig"] as string); }
public async Task UpdateDashboard() { int id; var overrides = new Dictionary <string, object> { { "Title", "Dashboard" }, { "OwnerTypeId", 1 }, { "DashboardConfig", "Some dash config" } }; var updatedValues = new Dictionary <string, object> { { "Title", "Updated title" }, { "OwnerTypeId", 2 }, { "DashboardConfig", "Updated Dash Config" } }; using (var context = await ContextFactory.CreateDbContext()) { context.Dashboards.AddRange(DashboardFactory.GetFactory(overrides).Generate()); context.SaveChanges(); id = context.Dashboards.First().Id; } var response1 = await Controller.UpdateDashboard(new Dashboard { Id = id, Title = updatedValues["Title"] as string, OwnerTypeId = (int)updatedValues["OwnerTypeId"], DashboardConfig = updatedValues["DashboardConfig"] as string }); var response2 = await Controller.GetDashboard(id); var result1 = CustomAssert.AssertOkResponse(response1); Assert.AreEqual(result1.Title, updatedValues["Title"] as string); Assert.AreEqual(result1.OwnerTypeId, (int)updatedValues["OwnerTypeId"]); Assert.AreEqual(result1.DashboardConfig, updatedValues["DashboardConfig"] as string); var result2 = CustomAssert.AssertOkResponse(response2); Assert.AreEqual(result2.Title, updatedValues["Title"] as string); Assert.AreEqual(result2.OwnerTypeId, (int)updatedValues["OwnerTypeId"]); Assert.AreEqual(result2.DashboardConfig, updatedValues["DashboardConfig"] as string); }