<commit_before>﻿using System;
using Coypu;
using NUnit.Framework;

namespace MonopolyTests.Tests
{
  [TestFixture]
  public class StartingAGameOfMonopoly : WebTestBase
  {
    [Test]
    public void When_anyone_visits_the_home_page__should_be_able_to_start_a_new_game()
    {
      browser.Visit("/");

      var link = browser.FindLink("Start a new game");

      Assert.IsTrue(link.Exists());
    }

    [Test]
    public void When_starting_a_new_game__should_be_able_to_fill_in_every_field_on_the_form()
    {
      browser.Visit("/NewGame");
      
      browser.FillIn("Name").With("Tron");
      browser.Choose("Dog");
      browser.FindFieldset("Opponent 1").Choose("P2Rube");
      browser.FindFieldset("Opponent 2").Choose("P3Chester");
      browser.FindFieldset("Opponent 3").Choose("P4Adolf");

      //Assert there is no error up to this point
    }

    [Test]
    public void When_submitting_the_form_for_a_new_game_with_missing_info__should_redirect_back_to_the_form_with_your_data_preserved()
    {
      browser.Visit("/NewGame");

      browser.FillIn("Name").With("Tron");
      browser.Choose("Dog");
      browser.FindFieldset("Opponent 1").Choose("P2Rube");
      browser.FindFieldset("Opponent 2").Choose("P3Chester");
      //everything filled in except 3rd opponent Adolf //browser.FindFieldset("Opponent 3").Choose("Adolf");

      browser.ClickButton("Submit");

      Assert.AreEqual(new Uri(baseUrl+"/NewGame"), browser.Location);
      Assert.AreEqual("Tron", browser.FindField("Name").Value);
      Assert.AreEqual("Dog", browser.FindField("Totem").Value);
      Assert.AreEqual("true", browser.FindField("P2Rube")["Checked"]); //"But Peter, why are you doing such horrible things with Checked attributes and mangling radio button names, when the API seems so much friendlier?" YOU CANT HANDLE THE TRUTH
      Assert.AreEqual("true", browser.FindField("P3Chester")["Checked"]);
    }

    [Test]
    public void When_submitting_the_form_for_a_new_game_with_different_missing_info__should_redirect_back_to_the_form_with_your_data_preserved()
    {
      browser.Visit("/NewGame");

      //nothing filled in, EXCEPT 3rd opponent Adolf
      browser.FindFieldset("Opponent 3").Choose("P4Adolf");

      browser.ClickButton("Submit");

      Assert.AreEqual(new Uri(baseUrl + "/NewGame"), browser.Location);
      Assert.AreEqual("true", browser.FindField("P4Adolf")["Checked"]);
    }
  }
}<commit_msg>add test for successfully starting a game<commit_after>﻿using System;
using Coypu;
using NUnit.Framework;

namespace MonopolyTests.Tests
{
  [TestFixture]
  public class StartingAGameOfMonopoly : WebTestBase
  {
    [Test]
    public void When_anyone_visits_the_home_page__should_be_able_to_start_a_new_game()
    {
      browser.Visit("/");

      var link = browser.FindLink("Start a new game");

      Assert.IsTrue(link.Exists());
    }

    [Test]
    public void When_starting_a_new_game__should_be_able_to_fill_in_every_field_on_the_form()
    {
      browser.Visit("/NewGame");
      
      browser.FillIn("Name").With("Tron");
      browser.Choose("Dog");
      browser.FindFieldset("Opponent 1").Choose("P2Rube");
      browser.FindFieldset("Opponent 2").Choose("P3Chester");
      browser.FindFieldset("Opponent 3").Choose("P4Adolf");

      //Assert there is no error up to this point
    }

    [Test]
    public void When_submitting_the_form_for_a_new_game_with_missing_info__should_redirect_back_to_the_form_with_your_data_preserved()
    {
      browser.Visit("/NewGame");

      browser.FillIn("Name").With("Tron");
      browser.Choose("Dog");
      browser.FindFieldset("Opponent 1").Choose("P2Rube");
      browser.FindFieldset("Opponent 2").Choose("P3Chester");
      //everything filled in except 3rd opponent Adolf //browser.FindFieldset("Opponent 3").Choose("P4Adolf");

      browser.ClickButton("Submit");

      Assert.AreEqual(new Uri(baseUrl+"/NewGame"), browser.Location);
      Assert.AreEqual("Tron", browser.FindField("Name").Value);
      Assert.AreEqual("Dog", browser.FindField("Totem").Value);
      Assert.AreEqual("true", browser.FindField("P2Rube")["Checked"]); //"But Peter, why are you doing such horrible things with Checked attributes and mangling radio button names, when the API seems so much friendlier?" YOU CANT HANDLE THE TRUTH
      Assert.AreEqual("true", browser.FindField("P3Chester")["Checked"]);
    }

    [Test]
    public void When_submitting_the_form_for_a_new_game_with_different_missing_info__should_redirect_back_to_the_form_with_your_data_preserved()
    {
      browser.Visit("/NewGame");

      //nothing filled in, EXCEPT 3rd opponent Adolf
      browser.FindFieldset("Opponent 3").Choose("P4Adolf");

      browser.ClickButton("Submit");

      Assert.AreEqual(new Uri(baseUrl + "/NewGame"), browser.Location);
      Assert.AreEqual("true", browser.FindField("P4Adolf")["Checked"]);
    }

    [Test]
    public void When_submitting_the_form_for_a_new_game_with_all_necessary_info__should_start_a_game()
    {
      browser.Visit("/NewGame");

      browser.FillIn("Name").With("Tron");
      browser.Choose("Dog");
      browser.FindFieldset("Opponent 1").Choose("P2Rube");
      browser.FindFieldset("Opponent 2").Choose("P3Chester");
      browser.FindFieldset("Opponent 3").Choose("P4Adolf");

      browser.ClickButton("Submit");

      Assert.AreEqual(new Uri(baseUrl + "/Game"), browser.Location);
    }

  }
}
{'fraction_non_alphanumeric': 0.13273029352039875, 'fraction_numerical': 0.007937973047812442, 'mean_word_length': 4.189655172413793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6647366', 'n_tokens_mistral': 1842, 'n_tokens_neox': 1684, 'n_words': 282}