public void WhenIAttemptToSetTheInsidePolicyToAnyConditionalGeofencePolicy() { ConditionalGeoFencePolicy interim_policy = new ConditionalGeoFencePolicy( inside: new MethodAmountPolicy(null), outside: new MethodAmountPolicy(null), fences: null, denyRootedJailbroken: false, denyEmulatorSimulator: false ); try { policy = new ConditionalGeoFencePolicy( outside: new MethodAmountPolicy(null), inside: interim_policy, fences: null, denyRootedJailbroken: false, denyEmulatorSimulator: false ); } catch (BaseException e) { _commonContext.RecordException(e); } }
public void Test_To_Transport_Works() { var expected = new TransportDomain.ConditionalGeoFencePolicy( DEFAULT_METHOD_AMOUNT_POLICY.ToTransport(), DEFAULT_FACTORS_POLICY.ToTransport(), false, false, new List <TransportDomain.IFence>() ); var policy = new ConditionalGeoFencePolicy( DEFAULT_METHOD_AMOUNT_POLICY, DEFAULT_FACTORS_POLICY, null, false, false ); TransportDomain.ConditionalGeoFencePolicy actual = (TransportDomain.ConditionalGeoFencePolicy)policy.ToTransport(); Assert.IsInstanceOfType(actual, typeof(TransportDomain.ConditionalGeoFencePolicy)); Assert.AreEqual(expected.DenyEmulatorSimulator, actual.DenyEmulatorSimulator); Assert.AreEqual(expected.DenyRootedJailbroken, actual.DenyRootedJailbroken); Assert.IsInstanceOfType(actual.Inside, typeof(TransportDomain.MethodAmountPolicy)); Assert.IsInstanceOfType(actual.Outside, typeof(TransportDomain.FactorsPolicy)); CollectionAssert.AreEquivalent(expected.Fences, actual.Fences); }
public void TestCreateCondGeoPolicy() { ConditionalGeoFencePolicy testPolicy = new ConditionalGeoFencePolicy( inside: DEFAULT_METHOD_AMOUNT_POLICY, outside: DEFAULT_METHOD_AMOUNT_POLICY, fences: null, denyEmulatorSimulator: false, denyRootedJailbroken: false ); Assert.AreEqual(false, testPolicy.DenyEmulatorSimulator); Assert.AreEqual(false, testPolicy.DenyRootedJailbroken); Assert.IsInstanceOfType(testPolicy.Fences, typeof(List <IFence>)); Assert.AreEqual(0, testPolicy.Fences.Count); Assert.IsInstanceOfType(testPolicy.Inside, typeof(MethodAmountPolicy)); Assert.IsInstanceOfType(testPolicy.Outside, typeof(MethodAmountPolicy)); }
public void TestInsideNestedConditionalGeofenceThrows() { ConditionalGeoFencePolicy nestedCondGeo = new ConditionalGeoFencePolicy( inside: DEFAULT_METHOD_AMOUNT_POLICY, outside: DEFAULT_METHOD_AMOUNT_POLICY, fences: null, denyEmulatorSimulator: true, denyRootedJailbroken: true ); Assert.ThrowsException <InvalidPolicyAttributes>(() => new ConditionalGeoFencePolicy( inside: nestedCondGeo, outside: DEFAULT_FACTORS_POLICY, fences: null, denyEmulatorSimulator: false, denyRootedJailbroken: false ) ); }
public void TestFencesAreCreated() { List <IFence> fences = new List <IFence>() { DEFAULT_GEOCIRCLE_FENCE, DEFAULT_TERRITORY_FENCE }; ConditionalGeoFencePolicy testPolicy = new ConditionalGeoFencePolicy( DEFAULT_METHOD_AMOUNT_POLICY, DEFAULT_METHOD_AMOUNT_POLICY, fences: fences, denyEmulatorSimulator: true, denyRootedJailbroken: true ); Assert.AreEqual(true, testPolicy.DenyEmulatorSimulator); Assert.AreEqual(true, testPolicy.DenyRootedJailbroken); CompareDefaultFences(testPolicy.Fences); Assert.IsInstanceOfType(testPolicy.Inside, typeof(MethodAmountPolicy)); Assert.IsInstanceOfType(testPolicy.Outside, typeof(MethodAmountPolicy)); }
public void Serialization_ConditionalGeofence_Works() { var json = "{" + "\"type\": \"COND_GEO\"," + "\"deny_emulator_simulator\": false," + "\"deny_rooted_jailbroken\": false," + "\"fences\": [" + "{" + "\"country\": \"CA\"," + "\"type\": \"TERRITORY\"," + "\"name\": \"Ontario\"," + "\"administrative_area\": \"CA-ON\"" + "}" + "]," + "\"inside\": {" + "\"fences\": []," + "\"type\": \"FACTORS\"," + "\"factors\": [" + "\"POSSESSION\"" + "]" + "}," + "\"outside\": {" + "\"fences\": []," + "\"amount\": 1," + "\"type\": \"METHOD_AMOUNT\"" + "}}"; FactorsPolicy factorsPolicy = new FactorsPolicy( factors: new List <string>() { "POSSESSION" }, denyEmulatorSimulator: null, denyRootedJailbroken: null, fences: new List <IFence>() ); MethodAmountPolicy methodAmountPolicy = new MethodAmountPolicy( fences: new List <IFence>(), denyEmulatorSimulator: null, denyRootedJailbroken: null, amount: 1 ); var expected = new ConditionalGeoFencePolicy( denyRootedJailbroken: false, denyEmulatorSimulator: false, fences: new List <IFence>() { new TerritoryFence(name: "Ontario", country: "CA", administrativeArea: "CA-ON") }, inside: factorsPolicy, outside: methodAmountPolicy); var actual = new JsonNetJsonEncoder().DecodeObject <ConditionalGeoFencePolicy>(json); actual.ShouldCompare(expected); FactorsPolicy inside = (FactorsPolicy)actual.Inside; MethodAmountPolicy outside = (MethodAmountPolicy)actual.Outside; Assert.IsNull(inside.DenyEmulatorSimulator); Assert.IsNull(inside.DenyRootedJailbroken); Assert.IsNull(outside.DenyEmulatorSimulator); Assert.IsNull(outside.DenyRootedJailbroken); }