public String Execute(String url, String teamName) { CheckoutServiceProxy.ICheckoutClient client = CheckoutServiceProxy.CheckoutClientFactory.create(url); Team team = new Team(); if (team.register(client, teamName)) { return String.Format("Successfully registered:'{0}'", team.Name); } else { return team.ErrorMessage; } }
public void ShouldRegisterTeam() { // Arrange String teamName = "AnyName"; Team team = new Team(); ICheckoutClient client = A.Fake<ICheckoutClient>(x => x.Strict()); A.CallTo(() => client.put<RegistrationResponse>("/Checkout/Team", A<RegistrationRequest>.Ignored)) .ReturnsLazily((String path, Object req) => Tuple.Create(System.Net.HttpStatusCode.Created, new RegistrationResponse { acceptedName = ((RegistrationRequest)req).name })); // Act bool registered = team.register(client, teamName); // Assert Assert.IsTrue(registered); Assert.AreEqual(teamName, team.Name); }