public void AddPermission(string PermissionName, bool IsExpectedToBeSuccessful) { DiSetup.Tests(); IPermissionService permissionService = DiHelper.GetService <IPermissionService>(); if (PermissionName.Equals("111") && IsExpectedToBeSuccessful.Equals(true)) { //only clear the first time permissionService.Clear(); } permissionService.CreateTestData(); int numberBefore = permissionService.GetPermissions().Count(); var result = permissionService.AddPermission(new Permission(PermissionName)); int numberAfter = permissionService.GetPermissions().Count(); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(bool)); if (IsExpectedToBeSuccessful) { Assert.AreEqual(true, result); Assert.AreEqual(numberAfter, numberBefore + 1); } else { Assert.AreEqual(false, result); Assert.AreEqual(numberAfter, numberBefore); } }
public void Resolve() { DiSetup.Tests(); TypedTestClient client = DiHelper.GetService <TypedTestClient>(new Uri("http://baseUri")); Assert.IsNotNull(client); }
public void Resolve() { DiSetup.Tests(); DiManager.GetInstance().RegisterInstance <INavigationPresenter>(new DummyNavigationPresenter()); var navigationService = DiHelper.GetService <INavigationService>(); Assert.IsNotNull(navigationService); }
public void IsNotNull() { DiSetup.Tests(); ITimeService timeService = DiHelper.GetService <ITimeService>(); Assert.IsNotNull(timeService); Assert.IsInstanceOfType(timeService, typeof(NET.efilnukefesin.Implementations.Timing.StandardTimeService)); }
public void CreateTestUsers() { DiSetup.Tests(); IUserService userService = DiHelper.GetService <IUserService>(); userService.CreateTestData(); Assert.AreEqual("88421113", userService.GetUserBySubject("88421113").Logins.ToList()[0].SubjectId); Assert.AreEqual("Bob", userService.GetUserBySubject("88421113").Name); }
public void GetRoles() { DiSetup.Tests(); IRoleService roleService = DiHelper.GetService <IRoleService>(); roleService.CreateTestData(); var result = roleService.GetRoles(); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IEnumerable <Role>)); }
public void Exists() { DiSetup.Tests(); IFeatureToggleManager featureToggleManager = DiHelper.GetService <IFeatureToggleManager>(); featureToggleManager.Clear(); featureToggleManager.Add(new StaticFeatureToggle("TestFeature", true)); Assert.AreEqual(true, featureToggleManager.Exists("TestFeature")); Assert.AreEqual(false, featureToggleManager.Exists("TestFeature2")); }
public void JumpTo() { DiSetup.Tests(); ITimeService timeService = DiHelper.GetService <ITimeService>(); TimeSpan target = new TimeSpan(3, 2, 1, 59, 999); timeService.JumpTo(target); Assert.IsTrue(StandardTimeServiceTests.timeEquals(target, timeService.ElapsedTimeRelative, new TimeSpan(0, 0, 1))); }
public void GetPermissions() { DiSetup.Tests(); IPermissionService permissionService = DiHelper.GetService <IPermissionService>(); permissionService.Clear(); permissionService.CreateTestData(); var result = permissionService.GetPermissions(); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IEnumerable <Permission>)); }
public void AddVersionbasedFeatureToggle() { DiSetup.Tests(); IFeatureToggleManager featureToggleManager = DiHelper.GetService <IFeatureToggleManager>(); featureToggleManager.Clear(); featureToggleManager.Add(new VersionbasedFeatureToggle("TestFeature", new Version(0, 8), this.GetType())); featureToggleManager.Add(new VersionbasedFeatureToggle("TestFeature2", new Version(1, 0), this.GetType())); //Assert.AreEqual(true, featureToggleManager.GetValue("TestFeature")); //Assert.AreEqual(false, featureToggleManager.GetValue("TestFeature2")); }
public void GetPermissions() { DiSetup.Tests(); IUserService userService = DiHelper.GetService <IUserService>(); userService.Clear(); userService.CreateTestData(); AuthenticationService authenticationService = DiHelper.GetService <AuthenticationService>(); var result = authenticationService.GetPermissions(); Assert.IsNotNull(result); Assert.IsTrue(result.Count() > 0); }
public void GetPermissionByName() { DiSetup.Tests(); IPermissionService permissionService = DiHelper.GetService <IPermissionService>(); permissionService.Clear(); permissionService.CreateTestData(); var result = permissionService.GetPermissionByName("User"); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(Permission)); Assert.AreEqual("User", result.Name); }
public void FastForward() { DiSetup.Tests(); ITimeService timeService = DiHelper.GetService <ITimeService>(); timeService.Play(); timeService.FastForward(2); Thread.Sleep(100); Assert.AreEqual(2, timeService.CurrentMultiplicator); Assert.IsNull(timeService.CurrentTarget); Assert.IsTrue(timeService.ElapsedTimeAbsolute < timeService.ElapsedTimeRelative); }
public void DeleteAsyncNotFound() { DiSetup.Tests(); var handlerMock = this.messageHandlerMockFaker(new HttpResponseMessage() { StatusCode = HttpStatusCode.NotFound }); TypedTestClient client = DiHelper.GetService <TypedTestClient>(new Uri("http://baseUri"), handlerMock.Object); bool result = client.DeleteAsync(1).GetAwaiter().GetResult(); Assert.IsNotNull(result); Assert.AreEqual(false, result); }
public void AddTimebasedFeatureToggle() { DiSetup.Tests(); IFeatureToggleManager featureToggleManager = DiHelper.GetService <IFeatureToggleManager>(); featureToggleManager.Clear(); featureToggleManager.Add(new TimebasedFeatureToggle("TestFeature", DateTimeOffset.Now + TimeSpan.FromMilliseconds(10))); featureToggleManager.Add(new TimebasedFeatureToggle("TestFeature2", DateTimeOffset.Now + TimeSpan.FromDays(1))); Thread.Sleep(20); Assert.AreEqual(true, featureToggleManager.GetValue("TestFeature")); Assert.AreEqual(false, featureToggleManager.GetValue("TestFeature2")); }
public void Play() { DiSetup.Tests(); ITimeService timeService = DiHelper.GetService <ITimeService>(); timeService.Align(); timeService.Play(); //TODO: address issue that this does not work in 'bunch run mode' Assert.AreEqual(1, timeService.CurrentMultiplicator); Assert.IsNull(timeService.CurrentTarget); Assert.IsTrue(StandardTimeServiceTests.timeEquals(timeService.ElapsedTimeAbsolute, timeService.ElapsedTimeRelative, new TimeSpan(0, 0, 1))); }
public void RewindWithTarget() { DiSetup.Tests(); ITimeService timeService = DiHelper.GetService <ITimeService>(); timeService.Play(); timeService.Rewind(2, new TimeSpan(0, 0, 0));; Thread.Sleep(100); Assert.AreEqual(-2, timeService.CurrentMultiplicator); Assert.AreEqual(new TimeSpan(0, 0, 0), timeService.CurrentTarget); Assert.IsTrue(timeService.ElapsedTimeAbsolute > timeService.ElapsedTimeRelative); }
public void Pause() { DiSetup.Tests(); ITimeService timeService = DiHelper.GetService <ITimeService>(); timeService.Play(); var testTime = timeService.ElapsedTimeRelative; timeService.Pause(); Thread.Sleep(100); Assert.AreEqual(0, timeService.CurrentMultiplicator); Assert.IsNull(timeService.CurrentTarget); Assert.AreEqual(testTime, timeService.ElapsedTimeRelative); }
public void GetAsync() { DiSetup.Tests(); var handlerMock = this.messageHandlerMockFaker(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = this.getContent <ValueObject <string> >(new ValueObject <string>("Hello World")), }); TypedTestClient client = DiHelper.GetService <TypedTestClient>(new Uri("http://baseUri"), handlerMock.Object); ValueObject <string> result = client.GetAsync(1).GetAwaiter().GetResult(); Assert.IsNotNull(result); Assert.AreEqual("Hello World", result.Value); }
public void SerializeRoles() { DiSetup.Tests(); IUserService userService = DiHelper.GetService <IUserService>(); userService.Clear(); userService.CreateTestData(); AuthenticationService authenticationService = DiHelper.GetService <AuthenticationService>(); var roles = authenticationService.GetRoles(); var result = JsonConvert.SerializeObject(new SimpleResult <IEnumerable <Role> >(roles)); var result2 = JsonConvert.DeserializeObject <SimpleResult <IEnumerable <Role> > >(result); Assert.IsNotNull(result); Assert.IsNotNull(result2); }
public void UnkownLogins() { DiSetup.Tests(); IUserService userService = DiHelper.GetService <IUserService>(); userService.CreateTestData(); userService.RegisterNewLogin("1", "[email protected]"); userService.RegisterNewLogin("2", "[email protected]"); userService.RegisterNewLogin("3", "[email protected]"); var result = userService.UnknownLogins; Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IEnumerable <Tuple <string, string> >)); Assert.AreEqual(3, result.Count()); }
public void PauseNegative() { DiSetup.Tests(); ITimeService timeService = DiHelper.GetService <ITimeService>(); timeService.Align(); timeService.Play(); var testTime = timeService.ElapsedTimeRelative; //timeService.Pause(); //<- do NOT pause here Thread.Sleep(100); Assert.AreNotEqual(0, timeService.CurrentMultiplicator); Assert.IsNull(timeService.CurrentTarget); Assert.IsTrue(testTime < timeService.ElapsedTimeRelative); //TODO: faisl in batch mode }
public void CreateOrUpdateAsync() { DiSetup.Tests(); var handlerMock = this.messageHandlerMockFaker(new HttpResponseMessage() { StatusCode = HttpStatusCode.Accepted }); var newItem = new ValueObject <string>("SomeThing"); TypedTestClient client = DiHelper.GetService <TypedTestClient>(new Uri("http://baseUri"), handlerMock.Object); bool result = client.CreateOrUpdateAsync(newItem).GetAwaiter().GetResult(); Assert.IsNotNull(result); Assert.AreEqual(true, result); }
public void AddPermission() { DiSetup.Tests(); IUserService userService = DiHelper.GetService <IUserService>(); userService.Clear(); userService.CreateTestData(); AuthenticationService authenticationService = DiHelper.GetService <AuthenticationService>(); int permissioncountBefore = authenticationService.GetPermissions().Count(); var result = authenticationService.AddPermission(new Models.Permission("SomePermission")); int permissioncountAfter = authenticationService.GetPermissions().Count(); Assert.IsNotNull(result); Assert.AreEqual(true, result); Assert.IsTrue(permissioncountBefore + 1 == permissioncountAfter); }
public void AddRole() { DiSetup.Tests(); IUserService userService = DiHelper.GetService <IUserService>(); userService.Clear(); userService.CreateTestData(); AuthenticationService authenticationService = DiHelper.GetService <AuthenticationService>(); int rolecountBefore = authenticationService.GetRoles().Count(); var result = authenticationService.AddRole(new Models.Role("SomeRole", null)); int rolecountAfter = authenticationService.GetRoles().Count(); Assert.IsNotNull(result); Assert.AreEqual(true, result); Assert.IsTrue(rolecountBefore + 1 == rolecountAfter); }
public void AddUser() { DiSetup.Tests(); IUserService userService = DiHelper.GetService <IUserService>(); userService.Clear(); userService.CreateTestData(); AuthenticationService authenticationService = DiHelper.GetService <AuthenticationService>(); int usercountBefore = authenticationService.GetUsers().Count(); var result = authenticationService.AddUser(new Models.User("Nigel Something")); int usercountAfter = authenticationService.GetUsers().Count(); Assert.IsNotNull(result); Assert.AreEqual(true, result); Assert.IsTrue(usercountBefore + 1 == usercountAfter); }
public void AddPermissionNegative() { DiSetup.Tests(); IUserService userService = DiHelper.GetService <IUserService>(); userService.Clear(); userService.CreateTestData(); AuthenticationService authenticationService = DiHelper.GetService <AuthenticationService>(); var existingPermission = authenticationService.GetPermissions().ToList()[0]; int permissioncountBefore = authenticationService.GetPermissions().Count(); var result = authenticationService.AddPermission(existingPermission); //try to add an existing user int permissioncountAfter = authenticationService.GetPermissions().Count(); Assert.IsNotNull(result); Assert.AreEqual(false, result); Assert.IsTrue(permissioncountBefore == permissioncountAfter); }
public void AddRoleNegative() { DiSetup.Tests(); IUserService userService = DiHelper.GetService <IUserService>(); userService.Clear(); userService.CreateTestData(); AuthenticationService authenticationService = DiHelper.GetService <AuthenticationService>(); var existingRole = authenticationService.GetRoles().ToList()[0]; int rolecountBefore = authenticationService.GetRoles().Count(); var result = authenticationService.AddRole(existingRole); //try to add an existing role int rolecountAfter = authenticationService.GetRoles().Count(); Assert.IsNotNull(result); Assert.AreEqual(false, result); Assert.IsTrue(rolecountBefore == rolecountAfter); }
public void AddUserNegative() { DiSetup.Tests(); IUserService userService = DiHelper.GetService <IUserService>(); userService.Clear(); userService.CreateTestData(); AuthenticationService authenticationService = DiHelper.GetService <AuthenticationService>(); var existingUser = authenticationService.GetUser("123"); int usercountBefore = authenticationService.GetUsers().Count(); var result = authenticationService.AddUser(existingUser); //try to add an existing user int usercountAfter = authenticationService.GetUsers().Count(); Assert.IsNotNull(result); Assert.AreEqual(false, result); Assert.IsTrue(usercountBefore == usercountAfter); }
public void GetUserByName(string Name, bool ExpectedToBeSuccessful) { DiSetup.Tests(); IUserService userService = DiHelper.GetService <IUserService>(); userService.CreateTestData(); var user = userService.GetUserByName(Name); if (ExpectedToBeSuccessful) { Assert.IsNotNull(user); Assert.IsInstanceOfType(user, typeof(User)); Assert.AreEqual(Name, user.Name); } else { Assert.IsNull(user); } }