Skip to content

Instantly share code, notes, and snippets.

@jamesmontemagno
Created April 6, 2017 15:29
Show Gist options
  • Select an option

  • Save jamesmontemagno/56e0e1bae7eabac6ebfd216aff6e252d to your computer and use it in GitHub Desktop.

Select an option

Save jamesmontemagno/56e0e1bae7eabac6ebfd216aff6e252d to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Plugin.Connectivity.Abstractions;
namespace UnitTestProject.Tests.Mock
{
public class MockConnectivity : IConnectivity
{
public bool IsConnected => true;
public IEnumerable<ConnectionType> ConnectionTypes => new[] { ConnectionType.WiFi };
public IEnumerable<ulong> Bandwidths => new[] { (ulong)4000 };
public event ConnectivityChangedEventHandler ConnectivityChanged;
public event ConnectivityTypeChangedEventHandler ConnectivityTypeChanged;
public void Dispose()
{
}
public Task<bool> IsReachable(string host, int msTimeout = 5000)
{
return Task.FromResult(true);
}
public Task<bool> IsRemoteReachable(string host, int port = 80, int msTimeout = 5000)
{
return Task.FromResult(true);
}
}
}
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using UnitTestingPlugins;
using UnitTestingPlugins.Helpers;
using UnitTestProject.Tests.Mock;
namespace UnitTestProject.Tests
{
[TestClass]
public class UnitTest1
{
[TestInitialize]
public void Setup()
{
Connectivity.Instance = new MockConnectivity();
}
[TestMethod]
public void TestMethod1()
{
var myClass = new MyClass();
Assert.AreEqual(5, myClass.Math(2, 3));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment