Пример #1
0
            public void PostsToTheCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new UsersClient(connection);

                var newUser = new NewUser("name", "*****@*****.**", true);

                client.Create(newUser);

                connection.Received().Post <User>(Arg.Is <Uri>(u => u.ToString() == "users"),
                                                  Arg.Is <NewUser>(df => df.Name == "name" &&
                                                                   df.Email == "*****@*****.**" &&
                                                                   df.ActiveFlag == true));
            }
Пример #2
0
        public void Users()
        {
            Utils.UseApiEnvironment((_, api, token) =>
            {
                using (var baseClient = api.CreateClient())
                {
                    IUsersClient client = new UsersClient(baseClient);

                    Assert.IsFalse(client.GetAll(token).Result.Any());
                    Assert.IsNull(client.Get(token, "0").Result);
                    client.Clear(token).Wait();
                    {
                        User tag = new User {
                            Name = "user"
                        };
                        string id = client.Create(token, Guid.NewGuid().ToString(), tag).Result;
                        Assert.AreEqual(tag.Name, client.Get(token, id).Result?.Name);
                        tag.Name = "user2";
                        Assert.IsNotNull(client.Update(token, id, tag).Result);
                        Assert.IsNotNull(client.Delete(token, id).Result);
                    }
                }
            });
        }
 public void Create_WithNull_ThrowException()
 {
     Assert.Throws <ArgumentNullException>(() => usersClient.Create(null));
 }
Пример #4
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new UsersClient(Substitute.For <IApiConnection>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null));
            }
 public void Create_WithNull_ThrowException()
 {
     usersClient.Create(null);
 }