Ejemplo n.º 1
0
        public async Task ViewModel_MessageCenter_ItemsViewModel_MessageCenter_DeleteData_Should_Pass()
        {
            MockForms.Init();

            // Get State of the DataStore, and set to run on the Mock
            var myDataStoreEnum = MasterDataStore.GetDataStoreMockFlag();

            MasterDataStore.ToggleDataStore(DataStoreEnum.Mock);

            var myViewModel = new ItemsViewModel();
            var myData      = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack);
            await myViewModel.AddAsync(myData);

            var myPage = new DeleteItemPage(new ItemDetailViewModel(new Item()));

            MessagingCenter.Send(myPage, "DeleteData", myData);

            var Actual = await myViewModel.GetAsync(myData.Id);

            Object Expected = null;

            // Return state
            MasterDataStore.ToggleDataStore(myDataStoreEnum);

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 2
0
        public async Task ViewModel_ItemsViewModel_UpdateData_Should_Pass()
        {
            MockForms.Init();

            // Get State of the DataStore, and set to run on the Mock
            var myDataStoreEnum = MasterDataStore.GetDataStoreMockFlag();

            MasterDataStore.ToggleDataStore(DataStoreEnum.Mock);

            var myViewModel = new ItemsViewModel();
            var myData      = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack);
            await myViewModel.AddAsync(myData);

            var value = "new";

            myData.Name = value;
            var myReturn = myViewModel.UpdateAsync(myData);

            var Actual = await myViewModel.GetAsync(myData.Id);

            string Expected = value;

            // Return state
            MasterDataStore.ToggleDataStore(myDataStoreEnum);

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual.Name, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 3
0
        public void Model_Item_FormatOutput_Name_WithSpace_Should_Pass()
        {
            Item myData;

            foreach (var attribute in AttributeList.GetListItem)
            {
                var attributeEnum = AttributeList.ConvertStringToEnum(attribute);

                foreach (var location in ItemLocationList.GetListItem)
                {
                    var locationEnum = ItemLocationList.ConvertStringToEnum(location);

                    myData = DefaultModels.ItemDefault(locationEnum, attributeEnum);

                    // Add leading space to name, to test the trim...
                    myData.Name = " " + myData.Name;

                    var Expected = "Item for " + location + " , Auto Created for " + location + " with " + attribute + "+" + myData.Value + " , Damage : " + myData.Damage + " , Range : " + myData.Range;

                    var Actual = myData.FormatOutput();

                    Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
                }
            }
        }
Ejemplo n.º 4
0
        public async Task ViewModel_ItemsViewModel_UpdateData_Bogus_Should_Skip()
        {
            MockForms.Init();

            // Get State of the DataStore, and set to run on the Mock
            var myDataStoreEnum = MasterDataStore.GetDataStoreMockFlag();

            MasterDataStore.ToggleDataStore(DataStoreEnum.Mock);

            var myViewModel = new ItemsViewModel();
            // Load data
            var canExecute = myViewModel.LoadDataCommand.CanExecute(null);

            myViewModel.LoadDataCommand.Execute(null);

            var myData = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack);

            // Make the ID bogus...
            var value = "new";

            myData.Id = value;

            var myReturn = await myViewModel.UpdateAsync(myData);

            var  Actual   = myReturn;
            bool Expected = false;

            // Return state
            MasterDataStore.ToggleDataStore(myDataStoreEnum);

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 5
0
        public void Model_Item_Update_With_Change_Should_Pass()
        {
            var Actual     = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack);
            var myActualId = Actual.Id;

            var Expected = DefaultModels.ItemDefault(ItemLocationEnum.Head, AttributeEnum.Speed);

            Expected.ImageURI    = "new uri";
            Expected.Name        = "new name";
            Expected.Description = "new description";
            Expected.Range       = 11;
            Expected.Value       = 22;
            Expected.Damage      = 33;

            Actual.Update(Expected);

            // Should not change with update...
            Assert.AreEqual(Actual.Id, myActualId, "Id " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Actual.Guid, Actual.Id, "Guid " + TestContext.CurrentContext.Test.Name);

            // Rest should match default for same request
            Assert.AreEqual(Expected.Attribute, Actual.Attribute, "Attribute " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Damage, Actual.Damage, "Damage " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Description, Actual.Description, "Description " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.ImageURI, Actual.ImageURI, "ImageURI " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Location, Actual.Location, "Location " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Name, Actual.Name, "Name " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Range, Actual.Range, "Range " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Value, Actual.Value, "Value " + TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 6
0
        public void Model_Item_Instantiate_Should_Pass()
        {
            // Walk all the Attributes and Locations and make an Item for each one
            // Verify the properties.

            Item myData;

            foreach (var attribute in AttributeList.GetListItem)
            {
                var attributeEnum = AttributeList.ConvertStringToEnum(attribute);

                foreach (var location in ItemLocationList.GetListItem)
                {
                    var locationEnum = ItemLocationList.ConvertStringToEnum(location);

                    myData = DefaultModels.ItemDefault(locationEnum, attributeEnum);


                    Assert.AreEqual(locationEnum, myData.Location, "location: " + location + " " + TestContext.CurrentContext.Test.Name);
                    Assert.AreEqual(attributeEnum, myData.Attribute, "attribute: " + attribute + " " + TestContext.CurrentContext.Test.Name);

                    Assert.AreEqual(1, myData.Value, "value " + TestContext.CurrentContext.Test.Name);
                    Assert.AreEqual(1, myData.Damage, "damage " + TestContext.CurrentContext.Test.Name);
                    Assert.AreEqual(1, myData.Range, "range " + TestContext.CurrentContext.Test.Name);


                    Assert.AreEqual("Item for " + location, myData.Name, "Name " + TestContext.CurrentContext.Test.Name);
                    Assert.AreEqual("Auto Created", myData.Description, "Description " + TestContext.CurrentContext.Test.Name);
                    Assert.AreEqual(null, myData.ImageURI, "range " + TestContext.CurrentContext.Test.Name);
                }
            }
        }
        public void ViewModel_ItemsViewModel_ChooseRandomItemString_With_No_Match_Should_Return_Null()
        {
            MockForms.Init();

            var myData = new ItemsViewModel();

            // Load Data
            myData.ForceDataRefresh();
            myData.Dataset.Clear();

            // Make an item for the feet
            var myItem = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack);

            myData.AddAsync(myItem).GetAwaiter().GetResult();

            // Ask for Any Item for the head
            var    Actual   = myData.ChooseRandomItemString(ItemLocationEnum.Head, AttributeEnum.Unknown);
            string Expected = null;

            // Load Data
            myData.ForceDataRefresh();

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 8
0
        public void Model_Score_AddItemToList_With_Null_Score_Should_Skip()
        {
            var myAdd  = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack);
            var myData = new Score();

            myData.AddItemToList(null);

            var    Actual   = myData.ItemsDroppedList;
            string Expected = null;

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 9
0
        public void Model_Score_AddItemToList_With_Valid_Should_Pass()
        {
            var myAdd  = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack);
            var myData = new Score();

            myData.AddItemToList(myAdd);

            var Actual   = myData.ItemsDroppedList;
            var Expected = "Item for Feet , Auto Created for Feet with Attack+1 , Damage : 1 , Range : 1\n";

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 10
0
        public void ViewModel_ItemsViewModel_Instantiate_With_Data_Should_Pass()
        {
            MockForms.Init();

            var myData = DefaultModels.ItemDefault(Game.Models.ItemLocationEnum.Feet, Game.Models.AttributeEnum.Attack);

            var value = "hi";

            myData.Name = value;
            var Actual = new ItemDetailViewModel(myData);

            Assert.AreEqual(value, Actual.Title, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 11
0
        public void ViewModel_ItemsViewModel_GetData_With_Data_Should_Pass()
        {
            MockForms.Init();

            var myData = DefaultModels.ItemDefault(Crawl.Models.ItemLocationEnum.Feet, Crawl.Models.AttributeEnum.Attack);

            var value = "hi";

            myData.Name = value;
            var myViewModel = new ItemDetailViewModel(myData);

            var Actual   = myViewModel.Data;
            var Expected = myData;

            Assert.AreEqual(Expected.Name, Actual.Name, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 12
0
        public void Model_Item_Create_With_Values_Should_Pass()
        {
            var Expected = DefaultModels.ItemDefault(ItemLocationEnum.Head, AttributeEnum.Speed);

            Expected.ImageURI    = "new uri";
            Expected.Name        = "new name";
            Expected.Description = "new description";
            Expected.Range       = 11;
            Expected.Value       = 22;
            Expected.Damage      = 33;

            var Actual = new Item(
                Expected.Name,
                Expected.Description,
                Expected.ImageURI,
                Expected.Range,
                Expected.Value,
                Expected.Damage,
                Expected.Location,
                Expected.Attribute
                );

            // The ID of the new item, should be unique
            Assert.AreNotEqual(Expected.Id, Actual.Id, "Id " + TestContext.CurrentContext.Test.Name);

            // The guid of the new item should match the ID of the new item.
            Assert.AreEqual(Expected.Guid, Expected.Id, "Guid " + TestContext.CurrentContext.Test.Name);

            // Rest should match default for same request
            Assert.AreEqual(Expected.Attribute, Actual.Attribute, "Attribute " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Damage, Actual.Damage, "Damage " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Description, Actual.Description, "Description " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.ImageURI, Actual.ImageURI, "ImageURI " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Location, Actual.Location, "Location " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Name, Actual.Name, "Name " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Range, Actual.Range, "Range " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Value, Actual.Value, "Value " + TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 13
0
        public void Model_Item_Update_With_Null_Should_Skip()
        {
            var Actual   = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack);
            var Expected = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack);

            var myActualId = Actual.Id;

            Actual.Update(null);

            // Should not change with update...
            Assert.AreEqual(Actual.Id, myActualId, "Id " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Actual.Guid, Actual.Id, "Guid " + TestContext.CurrentContext.Test.Name);

            // Rest should match default for same request
            Assert.AreEqual(Expected.Attribute, Actual.Attribute, "Attribute " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Damage, Actual.Damage, "Damage " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Description, Actual.Description, "Description " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.ImageURI, Actual.ImageURI, "ImageURI " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Location, Actual.Location, "Location " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Name, Actual.Name, "Name " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Range, Actual.Range, "Range " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Value, Actual.Value, "Value " + TestContext.CurrentContext.Test.Name);
        }