Created
April 6, 2017 15:29
-
-
Save jamesmontemagno/56e0e1bae7eabac6ebfd216aff6e252d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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