public void GetPropertyFromGameObject() { GameObject newGameObject = new GameObject("new game object"); Property newProperty = new Property(PropertyType.String, "new property", "a new value"); newGameObject.AddProperty(newProperty); Assert.IsTrue(newProperty.Value == newGameObject.GetProperty(newProperty.Name).Value); }
public void AddPropertyToGameObject() { GameObject newGameObject = new GameObject("new game object"); Property newProperty = new Property(PropertyType.String, "new property", "a new value"); Assert.IsTrue(newGameObject.AddProperty(newProperty)); Assert.IsTrue(newGameObject.DoesPropertyExist(newProperty.Name)); }
public void InvalidReceiveMesssage_RemoveProperty() { GameObject newGameObject = new GameObject("new game object"); Property newProperty = new Property(PropertyType.String, "new property", "a value"); newGameObject.AddProperty(newProperty); Message removeMessage = new Message(newGameObject.Name, MessageAction.Remove, "a name this is wrong or missing"); Response response = newGameObject.ReceiveMessage(removeMessage); Assert.IsFalse(response.Status); Assert.IsTrue(response.Value == "Property name does not exist"); Assert.IsTrue(response.PropType == PropType.Error); }
public void SaveDataToDrive() { GameObject gameObject = new GameObject("new game object"); Property newProperty = new Property(PropertyType.String, "new property", "new value"); gameObject.AddProperty(newProperty); GameObserver Observer = GameObserver.Instance; Observer.ObserveGameObject(gameObject, ObjectStatus.Active); GameData gameData = new GameData(Observer.GetObserverData()); GameArchive Archive = GameArchive.Instance; Archive.SaveData(gameData, "C:\\GameCraftData\\testgamedata.gcd"); Assert.IsTrue(true); }
public void InvalidReceiveMessage_AddProperty() { GameObject newGameObject = new GameObject("new game object"); Property newProperty = new Property(PropertyType.String, "new property", "a new value"); newGameObject.AddProperty(newProperty); Message newMessage = new Message(newGameObject.Name, MessageAction.Add, "new property", "a value", PropType.String); Response response = newGameObject.ReceiveMessage(newMessage); Assert.IsFalse(response.Status); Assert.IsTrue(response.Value == "Property name already exists"); Assert.IsTrue(response.Property == newProperty.Name); Assert.IsTrue(response.PropType == PropType.Error); }
public GameObject CloneGameObject() { GameObject newGameObject = new GameObject(Name); foreach (KeyValuePair<string, Property> prop in _properties) { newGameObject.AddProperty(prop.Value); } if (Image != null) { newGameObject.SetImage(Image.ConvertBinaryToImage()); } return newGameObject; }
public GameObject CloneGameObject() { GameObject newGameObject = new GameObject(Name); foreach (KeyValuePair <string, Property> prop in _properties) { newGameObject.AddProperty(prop.Value); } if (Image != null) { newGameObject.SetImage(Image.ConvertBinaryToImage()); } return(newGameObject); }
public void SetPropertyOnGameObject() { GameObject newGameObject = new GameObject("new game object"); Property newProperty = new Property(PropertyType.String, "new property", "a new value"); newGameObject.AddProperty(newProperty); string newPropValue = "even newer value "; Assert.IsTrue(newGameObject.SetProperty(newProperty.Name, newPropValue, newProperty.Type )); Assert.IsTrue(newGameObject.GetProperty(newProperty.Name).Value == newPropValue); }
public void ReceiveMessage_SetProperty() { GameObject newGameObject = new GameObject("new game object"); Property newProperty = new Property(PropertyType.String, "new property", "a value"); newGameObject.AddProperty(newProperty); Message setMessage = new Message(newGameObject.Name, MessageAction.Set, newProperty.Name,"a new value", PropType.String); Response response = newGameObject.ReceiveMessage(setMessage); Assert.IsTrue(response.Status); Assert.IsTrue(response.Property == newProperty.Name); Assert.IsTrue(response.Value != newProperty.Value); Assert.IsTrue(response.Value == newGameObject.GetProperty(newProperty.Name).Value); }
public void ReceiveMessage_RemoveProperty() { GameObject newGameObject = new GameObject("new game object"); Property newProperty = new Property(PropertyType.String, "new property", "a value"); newGameObject.AddProperty(newProperty); Message removeMessage = new Message(newGameObject.Name,MessageAction.Remove, newProperty.Name); Response response = newGameObject.ReceiveMessage(removeMessage); Assert.IsTrue(response.Status); Assert.IsTrue(response.Property == newProperty.Name); Assert.IsTrue(response.Value == "none"); Assert.IsFalse(newGameObject.DoesPropertyExist(newProperty.Name)); }