public async Task GeotabEmployeeProviderShouldCallApiLibraryOnUpdateEmployee()
        {
            //Arrange
            var api      = new FakeApi("a", "a", "a", "a", "a", 1000, new FakeHttpMessageHandler());
            var provider = new GeotabEmployeeProvider(api);

            //Act
            await provider.UpdateEmployee(_employeeWithProviders);

            //Assert
            //Since library does not have virtual member on Send call, cannot mock using Moq. Using fake http message handler and if Send gets
            //called a NotImplementedException will occur.
        }
Example #2
0
        //Fake Api :cry:
        public void FindTheNumber()
        {
            string response;

            FakeApiResult tryResult;

            int min        = 0;
            int max        = 50000;
            int testNumber = 25000;


            while (true)
            {
                response  = FakeApi.FakeApiRequest(testNumber);
                tryResult = JsonConvert.DeserializeObject <FakeApiResult>(response);



                if (tryResult.Result == FakeApiTryResult.Smaller.ToString())    // min.current do not change, max.current change to testNumber.current
                {
                    max         = testNumber;
                    testNumber  = GetMiddle(min, max);
                    NumberOfTry = tryResult.Try;
                }
                else if (tryResult.Result == FakeApiTryResult.Bigger.ToString())    // min.current change to testNumber.current, max.current do not change
                {
                    min         = testNumber;
                    testNumber  = GetMiddle(min, max);
                    NumberOfTry = tryResult.Try;
                }
                else if (tryResult.Result == "Try again !")
                {
                    EndText = "the algorithm is lost...";
                    break;
                }
                else
                {
                    EndText = "Congratulations !";
                    break;
                }
            }

            FoundNumber = testNumber;
            NumberOfTry++;

            IsRefreshing = false;
        }
 public void Init()
 {
     instance = new FakeApi();
 }
 public FakeApiTests()
 {
     instance = new FakeApi();
 }