Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Add TestClient to clean up tests #172

Merged
merged 1 commit into from
Feb 2, 2017
Merged

Add TestClient to clean up tests #172

merged 1 commit into from
Feb 2, 2017

Conversation

BrennanConroy
Copy link
Member

No description provided.

@dnfclas
Copy link

dnfclas commented Jan 30, 2017

Hi @BrennanConroy, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

@@ -0,0 +1,107 @@
using System;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Header

public IChannelConnection<Message> Application { get; }
public Task Connected => Connection.Metadata.Get<TaskCompletionSource<bool>>("ConnectedTask").Task;

public TestClient(IServiceProvider serviceProvider, string format = "json")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we generally like to avoid default params in constructors?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, especially in public API. Should be fine in tests though.

return false;
}

public void Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have Close and Dispose

await Application.Output.WriteAsync(new Message(buffer, Format.Binary, endOfMessage: true));
}

public async Task<T> Read<T>()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still need this? Is this the lower level API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. Client1 broadcasts to all clients, how else do we let Client2 see the message?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes. That makes sense.

using (message)
{
var serializer = new JsonSerializer();
value = serializer.Deserialize<T>(new JsonTextReader(new StreamReader(new MemoryStream(message.Payload.Buffer.ToArray()))));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this use the the adapter?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally :/
It adds a lot of complexity now.

@BrennanConroy
Copy link
Member Author

🆙 📅

@BrennanConroy
Copy link
Member Author

@anurse Happy

@moozzyk
Copy link
Contributor

moozzyk commented Feb 1, 2017

Looks good to me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants