Ejemplo n.º 1
0
        public IEnumerator UserCreatesTwoNetsWithAllErrors()
        {
            yield return(Install());

            yield return(0);

            // Checks initial state and clicks create button
            Assert.AreEqual(1, GameObject.FindObjectsOfType <DataNetCreationErrorDisplay>().Length);
            DataNetCreationErrorDisplay errorDisplay = GameObject.FindObjectOfType <DataNetCreationErrorDisplay>();

            Assert.AreEqual(_creationData.GetHashCode(), errorDisplay.CreationData.GetHashCode());
            checkErrorDisplayEmpty(errorDisplay);
            DataNetNameInput nameInput = GameObject.FindObjectOfType <DataNetNameInput>();

            Assert.AreEqual(_creationData.GetHashCode(), nameInput.CreationData.GetHashCode());
            checkInputFieldEmpty(nameInput);
            DataNetCreationButton creationButton = GameObject.FindObjectOfType <DataNetCreationButton>();

            creationButton.Button.onClick.Invoke();
            yield return(0);

            // Checks error display and enters first net name
            checkErrorDisplayed(errorDisplay);
            enterName(nameInput, _firstNetName);
            yield return(0);

            // Checks error not displayed anymore and clicks create button
            checkErrorDisplayEmpty(errorDisplay);
            creationButton.Button.onClick.Invoke();
            yield return(0);

            // Checks if net and also the list element have been created and enters the name of the first net again.
            NetSelectionElementsCreator netSelectionElementsCreator = GameObject.FindObjectOfType <NetSelectionElementsCreator>();

            checkNetElementsCreated(netSelectionElementsCreator);
            checkInputFieldEmpty(nameInput);
            enterName(nameInput, _firstNetName);
            creationButton.Button.onClick.Invoke();
            yield return(0);

            // Checks if the expected error is display, enters second net name and clicks create button
            checkErrorDisplayed(errorDisplay);
            enterName(nameInput, _secondNetName);
            creationButton.Button.onClick.Invoke();
            yield return(0);

            // Checks if the error display is empty,
            // checks if second net has been created,
            // checks if name input is empty,
            checkNetElementsCreated(netSelectionElementsCreator);
            checkInputFieldEmpty(nameInput);
            checkErrorDisplayEmpty(errorDisplay);
        }
Ejemplo n.º 2
0
 private void checkInputFieldEmpty(DataNetNameInput input)
 {
     Assert.AreEqual(string.Empty, _creationData.Name);
     Assert.AreEqual(string.Empty, input.InputField.text);
 }
Ejemplo n.º 3
0
 private void enterName(DataNetNameInput nameInput, string name)
 {
     nameInput.InputField.text = name;
     nameInput.InputField.onValueChanged.Invoke(name);
     nameInput.InputField.onEndEdit.Invoke(name);
 }