protected override IObservable <IClient> CallEndpointWith(ITogglApi togglApi) => Observable.Defer(async() => { var user = await togglApi.User.Get(); var client = new Client { Name = Guid.NewGuid().ToString(), WorkspaceId = user.DefaultWorkspaceId.Value }; return(CallEndpointWith(togglApi, client)); });
protected override async Task <IClient> CallEndpointWith(ITogglApi togglApi) { var user = await togglApi.User.Get(); var client = new Client { Name = Guid.NewGuid().ToString(), WorkspaceId = user.DefaultWorkspaceId.Value }; return(await CallEndpointWith(togglApi, client)); }
public async Task CreatesNewClient() { var(togglClient, user) = await SetupTestUser(); var newClient = new Client { Name = Guid.NewGuid().ToString(), WorkspaceId = user.DefaultWorkspaceId.Value }; var persistedClient = await CallEndpointWith(togglClient, newClient); persistedClient.Name.Should().Be(newClient.Name); persistedClient.WorkspaceId.Should().Be(newClient.WorkspaceId); }
public async Task ReturnsAllClients() { var(togglClient, user) = await SetupTestUser(); var firstClient = new Client { Name = "First", WorkspaceId = user.DefaultWorkspaceId.Value }; var firstClientPosted = await togglClient.Clients.Create(firstClient); var secondClient = new Client { Name = "Second", WorkspaceId = user.DefaultWorkspaceId.Value }; var secondClientPosted = await togglClient.Clients.Create(secondClient); var clients = await CallEndpointWith(togglClient); clients.Should().HaveCount(2); clients.Should().Contain(clientWithSameIdNameAndWorkspaceAs(firstClientPosted)); clients.Should().Contain(clientWithSameIdNameAndWorkspaceAs(secondClientPosted)); }