public void Controller_Kiosk_KioskLogout_Valid_Data_Should_Update_Status() { // Arrange DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(true); var controller = new KioskController(); // Get the first Studnet from the DataSource var data = DataSourceBackend.Instance.StudentBackend.GetDefault(); var id = DataSourceBackend.Instance.StudentBackend.GetDefault().Id; // Login, so logout can happen controller.KioskLogin(data); // Act var result = (RedirectToRouteResult)controller.KioskLogout(data); // check status change after KioskLogout var resultStatus = DataSourceBackend.Instance.StudentBackend.Read(id).Status; // Reset DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual(StudentStatusEnum.Out, resultStatus, TestContext.TestName); }
public void Backend_DataSourceBackendTable_ConvertFromEntityList_Valid_List_Should_Return() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = DataSourceBackendTable.Instance; var temp = new DataSourceBackendTableEntity { PartitionKey = "pk", RowKey = "rk" }; var tempblob = new AvatarItemModel(); var entity = backend.ConvertToEntity <AvatarItemModel>(tempblob, temp.PartitionKey, temp.RowKey); var data = new List <DataSourceBackendTableEntity> { entity }; // Act var result = backend.ConvertFromEntityList <AvatarItemModel>(data); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.IsNotNull(result, TestContext.TestName); }
public void Controller_Student_Update_Get_myData_Is_Null_Should_Return_Error_Page() { // Arrange StudentController controller = new StudentController(); string id = DataSourceBackend.Instance.StudentBackend.GetDefault().Id; // Reset DataSourceBackend DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(true); var context = CreateMoqSetupForCookie(); controller.ControllerContext = new ControllerContext(context, new RouteData(), controller); // Act var result = (RedirectToRouteResult)controller.Update(id); // Reset DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual("Error", result.RouteValues["action"], TestContext.TestName); Assert.AreEqual("Home", result.RouteValues["controller"], TestContext.TestName); }
public ActionResult Login([Bind(Include = "Id," + "Name," + "Description," + "Uri," + "AvatarLevel," + "Tokens," + "Status," + "Password," + "ExperiencePoints," + "Password," + "")] StudentDisplayViewModel data) { // Any password is accepted for now. does not really login... if (!ModelState.IsValid) { // Send back for edit, with Error Message return(View(data)); } if (data == null) { // Send to Error Page return(RedirectToAction("Error", "Home")); } if (string.IsNullOrEmpty(data.Id)) { // Send back for Edit return(RedirectToAction("Error", "Home")); } var myStudent = DataSourceBackend.Instance.StudentBackend.Read(data.Id); if (myStudent == null) { // Send to Error Page //return RedirectToAction("Error", "Home"); return(RedirectToAction("Roster", "Portal")); } // When not in testing mode try the password if (!DataSourceBackend.GetTestingMode()) { if (!DataSourceBackend.Instance.IdentityBackend.LogUserIn(myStudent.Name, data.Password, _5051.Models.UserRoleEnum.StudentUser, HttpContext)) { ModelState.AddModelError("", "Invalid password"); var myReturn = new StudentDisplayViewModel(myStudent); return(View(myReturn)); } } // all is OK, so redirect to the student index page and pass in the student ID for now. return(RedirectToAction("Index", "Portal", new { id = data.Id })); }
public void DataSource_GetTestingMode_Should_Pass() { // Arrange // Act var result = DataSourceBackend.GetTestingMode(); // Reset // Assert Assert.AreEqual(false, result); }
public void DataSource_SetTestingMode_False_Should_Pass() { // Arrange var currentMode = DataSourceBackend.GetTestingMode(); // Act DataSourceBackend.SetTestingMode(false); var newMode = DataSourceBackend.GetTestingMode(); // Reset DataSourceBackend.SetTestingMode(currentMode); // Assert Assert.AreEqual(false, newMode); }
public void Backend_AvatarItemDataSourceTable_Read_Invalid_ID_Null_Should_Fail() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = AvatarItemDataSourceTable.Instance; // Act var result = backend.Read(null); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.IsNull(result, TestContext.TestName); }
public void Backend_FactoryInventoryDataSourceTable_Update_Invalid_Data_Null_Should_Fail() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = FactoryInventoryDataSourceTable.Instance; // Act var result = backend.Update(null); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.IsNull(result, TestContext.TestName); }
public void Backend_AvatarItemDataSourceTable_Delete_Invalid_ID_Bogus_Should_Fail() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = AvatarItemDataSourceTable.Instance; var expect = false; // Act var result = backend.Delete("bogus"); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.AreEqual(expect, result, TestContext.TestName); }
public void Backend_AvatarItemDataSourceTable_Update_Invalid_Data_Shop_Item_Does_Not_Exist_Should_Fail() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = AvatarItemDataSourceTable.Instance; var expectShopModel = new AvatarItemModel(); // Act var result = backend.Update(expectShopModel); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.IsNull(result, TestContext.TestName); }
public void Backend_DataSourceBackendTable_ConvertFromEntityList_Valid_Should_Return() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = DataSourceBackendTable.Instance; var data = new List <DataSourceBackendTableEntity>(); // Act var result = backend.ConvertFromEntityList <AvatarItemModel>(data); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.IsNotNull(result, TestContext.TestName); }
public void Backend_DataSourceBackendTable_SetDataSourceServerModeDirect_InValid_String_Should_Return() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = DataSourceBackendTable.Instance; //var expectEnum = DataSourceEnum.ServerLive; // Act var result = backend.SetDataSourceServerModeDirect("bogus"); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.IsFalse(result, TestContext.TestName); }
public void Backend_FactoryInventoryDataSourceTable_Delete_Invalid_ID_Null_Should_Fail() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = FactoryInventoryDataSourceTable.Instance; var expect = false; // Act var result = backend.Delete(null); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.AreEqual(expect, result, TestContext.TestName); }
public void Backend_AvatarItemDataSourceTable_Read_Valid_ID_Should_Pass() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = AvatarItemDataSourceTable.Instance; var shopBackend = AvatarItemBackend.Instance; var expectShopItem = shopBackend.GetFirstAvatarItemId(); // Act var result = backend.Read(expectShopItem); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.IsNotNull(result, TestContext.TestName); }
public void Backend_DataSourceBackendTable_LoadAll_Valid_Should_Return() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = DataSourceBackendTable.Instance; var table = "AvatarItemModel".ToLower(); var pk = table; // Act var result = backend.LoadAll <AvatarItemModel>(table, pk); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.AreEqual(0, result.Count, TestContext.TestName); }
public void Backend_AvatarItemDataSourceTable_LoadDataSet_Valid_Enum_UnitTest_Should_Pass() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = AvatarItemDataSourceTable.Instance; var expectEnum = _5051.Models.DataSourceDataSetEnum.UnitTest; // Act backend.LoadDataSet(expectEnum); var result = backend; // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.IsNotNull(result, TestContext.TestName); }
public void Backend_DataSourceBackendTable_LoadAllDirect_Invalid_pk_Null_Should_Fail() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = DataSourceBackendTable.Instance; var table = "AvatarItemModel".ToLower(); var pk = table; // Act var result = backend.LoadAllDirect <AvatarItemModel>(table, null, DataSourceEnum.Unknown, false); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.AreEqual(0, result.Count, TestContext.TestName); }
public void Backend_DataSourceBackendTable_SetDataSourceServerMode_Valid_Enum_ServerLive_Should_Pass() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = DataSourceBackendTable.Instance; var expectEnum = DataSourceEnum.ServerLive; // Act backend.SetDataSourceServerMode(expectEnum); var result = backend; // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.IsNotNull(result, TestContext.TestName); }
public void Controller_AvatarSelectShop_Select_Get_myDataIsNull_ShouldReturnErrorPage() { // Arrange var controller = new AvatarSelectController(); var id = DataSourceBackend.Instance.StudentBackend.GetDefault().Id; // Reset DataSourceBackend DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(true); // Act var result = (RedirectToRouteResult)controller.Select(id); // Reset DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual("Error", result.RouteValues["action"], TestContext.TestName); Assert.AreEqual("Home", result.RouteValues["controller"], TestContext.TestName); }
public void Backend_DataSourceBackendTable_ConvertToEntity_Valid_Should_Return() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = DataSourceBackendTable.Instance; var data = new AvatarItemModel(); var table = "AvatarItemModel".ToLower(); var pk = table; var rk = "rk"; // Act var result = backend.ConvertToEntity <AvatarItemModel>(data, pk, rk); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.IsNotNull(result, TestContext.TestName); }
public void Backend_DataSourceBackendTable_DeleteDirect_Valid_Should_Return() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = DataSourceBackendTable.Instance; var data = new AvatarItemModel(); var table = "AvatarItemModel".ToLower(); var pk = table; var rk = "rk"; // Act var result = backend.DeleteDirect <AvatarItemModel>(table, pk, rk); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.AreEqual(true, result, TestContext.TestName); }
public void Backend_DataSourceBackendTable_Load_Invalid_pk_Null_Should_Fail() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = DataSourceBackendTable.Instance; var data = new AvatarItemModel(); var table = "AvatarItemModel".ToLower(); var pk = table; var rk = "rk"; // Act var result = backend.Load <AvatarItemModel>(table, null, rk); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.IsNull(result, TestContext.TestName); }
public void Controller_Kiosk_KioskLogin_Valid_Data_Should_Pass() { // Arrange DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(true); var controller = new KioskController(); // Get the first Studnet from the DataSource var data = DataSourceBackend.Instance.StudentBackend.GetDefault(); var id = DataSourceBackend.Instance.StudentBackend.GetDefault().Id; // Act var result = (RedirectToRouteResult)controller.KioskLogin(data); // Reset DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual("ConfirmLogin", result.RouteValues["action"], TestContext.TestName); }
public void Backend_DataSourceBackendTable_Default_Instantiate_Should_Pass() { // Arrange DataSourceBackend.SetTestingMode(true); // Set for ServerTest DataSourceBackend.Instance.SetDataSource(DataSourceEnum.ServerTest); var backend = DataSourceBackend.Instance; //var expect = backend; // Act var result = backend.AvatarItemBackend; // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.IsNotNull(result, TestContext.TestName); }
public void Backend_AvatarItemDataSourceTable_Update_Valid_Data_Should_Pass() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = AvatarItemDataSourceTable.Instance; var shopBackend = AvatarItemBackend.Instance; var expectShopItemId = shopBackend.GetFirstAvatarItemId(); var expectShopModel = backend.Read(expectShopItemId); var expectId = "GoodID"; var expectUri = "GoodUri"; var expectName = "Shop Item"; var expectDescription = "A good description of the item"; var expectCatagory = AvatarItemCategoryEnum.Accessory; var expectTokens = 1000; // Act expectShopModel.Id = expectId; expectShopModel.Uri = expectUri; expectShopModel.Name = expectName; expectShopModel.Description = expectDescription; expectShopModel.Category = expectCatagory; expectShopModel.Tokens = expectTokens; var resultUpdate = backend.Update(expectShopModel); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.AreEqual(expectShopModel, resultUpdate, TestContext.TestName); Assert.AreEqual(expectId, resultUpdate.Id, TestContext.TestName); Assert.AreEqual(expectUri, resultUpdate.Uri, TestContext.TestName); Assert.AreEqual(expectName, resultUpdate.Name, TestContext.TestName); Assert.AreEqual(expectDescription, resultUpdate.Description, TestContext.TestName); Assert.AreEqual(expectCatagory, resultUpdate.Category, TestContext.TestName); Assert.AreEqual(expectTokens, resultUpdate.Tokens, TestContext.TestName); }
public void Backend_AvatarItemDataSourceTable_Delete_Valid_ID_Should_Pass() { // Arrange DataSourceBackend.SetTestingMode(true); var backend = AvatarItemDataSourceTable.Instance; DataSourceBackend.Instance.SetDataSource(DataSourceEnum.Local); var shopBackend = DataSourceBackend.Instance.AvatarItemBackend; var expectShopItem = shopBackend.GetFirstAvatarItemId(); var expect = true; // Act var result = backend.Delete(expectShopItem); // Reset DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(false); // Assert Assert.AreEqual(expect, result, TestContext.TestName); }
public void Controller_Kiosk_KioskLogin_Valid_Data_Should_Update_Emotion() { // Arrange DataSourceBackend.Instance.Reset(); DataSourceBackend.SetTestingMode(true); var controller = new KioskController(); // Get the first Studnet from the DataSource var data = DataSourceBackend.Instance.StudentBackend.GetDefault(); string id = DataSourceBackend.Instance.StudentBackend.GetDefault().Id; // Act var result = (RedirectToRouteResult)controller.KioskLogin(data); // check status change after SetLogin var resultStatus = DataSourceBackend.Instance.StudentBackend.Read(id).EmotionCurrent; // Reset DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual(EmotionStatusEnum.Neutral, resultStatus, TestContext.TestName); }
public void Cleanup() { DataSourceBackend.SetTestingMode(false); DataSourceBackend.Instance.SetDataSource(DataSourceEnum.Mock); }
public void TestInitialize() { DataSourceBackend.SetTestingMode(true); }
public void Initialize() { DataSourceBackend.SetTestingMode(true); DataSourceBackend.Instance.SetDataSource(DataSourceEnum.Local); }