コード例 #1
0
            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);
                }
            }
コード例 #2
0
            public void Resolve()
            {
                DiSetup.Tests();

                TypedTestClient client = DiHelper.GetService <TypedTestClient>(new Uri("http://baseUri"));

                Assert.IsNotNull(client);
            }
コード例 #3
0
            public void Resolve()
            {
                DiSetup.Tests();
                DiManager.GetInstance().RegisterInstance <INavigationPresenter>(new DummyNavigationPresenter());

                var navigationService = DiHelper.GetService <INavigationService>();

                Assert.IsNotNull(navigationService);
            }
コード例 #4
0
            public void IsNotNull()
            {
                DiSetup.Tests();

                ITimeService timeService = DiHelper.GetService <ITimeService>();

                Assert.IsNotNull(timeService);
                Assert.IsInstanceOfType(timeService, typeof(NET.efilnukefesin.Implementations.Timing.StandardTimeService));
            }
コード例 #5
0
            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);
            }
コード例 #6
0
            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>));
            }
コード例 #7
0
            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"));
            }
コード例 #8
0
            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)));
            }
コード例 #9
0
            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>));
            }
コード例 #10
0
            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"));
            }
コード例 #11
0
            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);
            }
コード例 #12
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);
            }
コード例 #13
0
            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);
            }
コード例 #14
0
            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);
            }
コード例 #15
0
            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"));
            }
コード例 #16
0
            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)));
            }
コード例 #17
0
            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);
            }
コード例 #18
0
            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);
            }
コード例 #19
0
            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);
            }
コード例 #20
0
            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);
            }
コード例 #21
0
            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());
            }
コード例 #22
0
            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
            }
コード例 #23
0
            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);
            }
コード例 #24
0
            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);
            }
コード例 #25
0
            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);
            }
コード例 #26
0
            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);
            }
コード例 #27
0
            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);
            }
コード例 #28
0
            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);
            }
コード例 #29
0
            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);
            }
コード例 #30
0
            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);
                }
            }