public void CreateMessageHandler_Null_ArgumentNullException() { // Arrange MessageHandlerFactory factory = new MessageHandlerFactory(); // Act / Assert Assert.Throws <ArgumentNullException>(() => factory.CreateMessageHandler <IMessage>(null)); }
public void CreateMessageHandler_ValidCallback_IMessageHandler() { // Arrange MessageHandlerFactory factory = new MessageHandlerFactory(); IMessageHandler messageHandler; // Act messageHandler = factory.CreateMessageHandler <IMessage>(HandleMessage); // Assert Assert.NotNull(messageHandler); }
public static void AssemblyInitialize(TestContext context) { // set the http message handler factory to the mode we want for the entire assmebly test execution MessageHandlerFactory.Mode = MessageHandlerMode.Fake; // setup IOC so test classes can get the shared message handler ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); // responses are in a ziparchive that is also referenced by the DeploymentItem attributes var resources = new ZipResources(Path.Combine(context.DeploymentDirectory, "FakeResponses.zip")); SimpleIoc.Default.Register(() => MessageHandlerFactory.CreateMessageHandler(resources)); }
public static void AssemblyInitialize(TestContext context) { // set the http message handler factory to the mode we want for the entire assmebly test execution MessageHandlerFactory.Mode = MessageHandlerMode.Fake; // folders where mock responses are stored and where captured response should be saved var mockFolder = context.DeploymentDirectory; // the folder where the unit tests are running var captureFolder = Path.Combine(context.TestRunDirectory, @"..\..\MockResponses\"); // kinda hacky but this should be the solution folder // here we don't want to serialize or include our api key in response lookups so // pass a lambda that will indicate to the serialzier to filter that param out var store = new FileSystemResources(mockFolder); Handler = MessageHandlerFactory.CreateMessageHandler(store); }
public async Task RoundtripPostalCode() { MessageHandlerFactory.Mode = MessageHandlerMode.Capture; var handler = MessageHandlerFactory.CreateMessageHandler(new FileSystemResources(TestContext.TestRunDirectory)); var service = new GeoCoder(handler, CredentialStore.RetrieveObject("bing.key.json").Key); var coord = await service.GetCoordinate(new Address() { postalCode = "55116", countryRegion = "US" }); var address = await service.GetAddress(coord.Item1, coord.Item2); Assert.AreEqual("55116", address.postalCode); }