public void CreateOrUpdateAsyncWithDelegate()
            {
                DiSetup.FileDataServiceTests();
                DiSetup.InitializeFileEndpoints();

                IDataService dataService  = DiHelper.GetService <IDataService>(this.testPath);
                int          numberBefore = dataService.GetAllAsync <ValueObject <string> >("CreateOrUpdateAsyncTest5Action").GetAwaiter().GetResult().Count();

                List <ValueObject <string> > items = new List <ValueObject <string> >();

                items.Add(new ValueObject <string>("TestString1"));
                items.Add(new ValueObject <string>("TestString2"));
                items.Add(new ValueObject <string>("TestString3"));
                items.Add(new ValueObject <string>("TestString4"));

                dataService.CreateOrUpdateAsync <ValueObject <string> >("CreateOrUpdateAsyncTest5Action", items).GetAwaiter().GetResult();

                bool resultAdd    = dataService.CreateOrUpdateAsync <ValueObject <string> >("CreateOrUpdateAsyncTest5Action", new ValueObject <string>("TestString"), x => x.Value.Equals("DunnoYet")).GetAwaiter().GetResult();
                bool resultUpdate = dataService.CreateOrUpdateAsync <ValueObject <string> >("CreateOrUpdateAsyncTest5Action", new ValueObject <string>("TestString"), x => x.Value.Equals("TestString4")).GetAwaiter().GetResult();

                int numberAfterwards = dataService.GetAllAsync <ValueObject <string> >("CreateOrUpdateAsyncTest5Action").GetAwaiter().GetResult().Count();

                Assert.AreEqual(true, resultAdd);
                Assert.AreEqual(true, resultUpdate);
                Assert.AreEqual(5, numberAfterwards - numberBefore);
            }
Exemple #2
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);
                }
            }
Exemple #3
0
        public IResult <string> Get()
        {
            var s = DiHelper.CreateInstance <SomeoneClass>();

            var x = DiHelper.GetService <IStudentServic>();

            return(this.Success(someone.SomeoneMethod() + s.SomeoneMethod() + x.GetStudent2().Result.StudentName));
        }
Exemple #4
0
            public void Resolve()
            {
                DiSetup.Tests();

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

                Assert.IsNotNull(client);
            }
            public void IsNotNull()
            {
                DiSetup.Tests();

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

                Assert.IsNotNull(timeService);
                Assert.IsInstanceOfType(timeService, typeof(NET.efilnukefesin.Implementations.Timing.StandardTimeService));
            }
            public void IsNotNull()
            {
                DiSetup.FileDataServiceTests();

                IDataService dataService = DiHelper.GetService <IDataService>(this.testPath);

                Assert.IsNotNull(dataService);
                Assert.IsInstanceOfType(dataService, typeof(NET.efilnukefesin.Implementations.Services.DataService.FileDataService.FileDataService));
            }
Exemple #7
0
            public void Resolve()
            {
                DiSetup.Tests();
                DiManager.GetInstance().RegisterInstance <INavigationPresenter>(new DummyNavigationPresenter());

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

                Assert.IsNotNull(navigationService);
            }
            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 IsNotNull()
            {
                DiSetup.RestDataServiceTests();
                DiSetup.InitializeRestEndpoints();

                IDataService dataService = DiHelper.GetService <IDataService>(new Uri("http://baseUri"), "someToken");

                Assert.IsNotNull(dataService);
                Assert.IsInstanceOfType(dataService, typeof(NET.efilnukefesin.Implementations.Services.DataService.RestDataService.RestDataService));
            }
            public void DeleteAsync()
            {
                DiSetup.FileDataServiceTests();
                DiSetup.InitializeFileEndpoints();

                IDataService dataService = DiHelper.GetService <IDataService>(this.testPath);

                bool result = dataService.DeleteAsync <ValueObject <string> >("DeleteAsyncTest1Action", "Opel").GetAwaiter().GetResult();

                Assert.AreEqual(true, result);
            }
            public void CreateOrUpdateAsyncAppend()
            {
                DiSetup.FileDataServiceTests();
                DiSetup.InitializeFileEndpoints();

                IDataService dataService = DiHelper.GetService <IDataService>(this.testPath);

                bool result = dataService.CreateOrUpdateAsync <ValueObject <string> >("CreateOrUpdateAsyncTest1Action", new ValueObject <string>("TestString")).GetAwaiter().GetResult();

                Assert.AreEqual(true, result);
            }
            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 GetAllAsyncInt()
            {
                DiSetup.FileDataServiceTests();
                DiSetup.InitializeFileEndpoints();

                IDataService dataService = DiHelper.GetService <IDataService>(this.testPath);

                var result = dataService.GetAllAsync <ValueObject <int> >("GetAsyncTest4Action").GetAwaiter().GetResult();

                Assert.IsNotNull(result);
                Assert.AreEqual(123, result.ToList()[0].Value);
            }
            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 GetEndpoint()
            {
                DiSetup.RestDataServiceTests();
                IEndpointRegister endpointRegister = DiHelper.GetService <IEndpointRegister>();
                bool wasSuccessfullyAdded          = endpointRegister.AddEndpoint("SomeEndpointTest", "TestString");

                string result = endpointRegister.GetEndpoint("SomeEndpointTest");

                Assert.AreEqual(true, wasSuccessfullyAdded);
                Assert.IsNotNull(result);
                Assert.AreEqual("TestString", result);
            }
Exemple #16
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>));
            }
Exemple #17
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>));
            }
            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"));
            }
        //[TestMethod]
        public async Task AskSpecialEndpoint()
        {
            DiSetup.RestDataServiceTests();
            DiSetup.InitializeRestEndpoints();

            this.startLocalServer();

            IDataService dataService = DiHelper.GetService <IDataService>(this.localServerUri, this.getHttpClientHandler());

            var result = await dataService.GetAsync <ValueObject <bool> >("SpecialValueStore", "1", "Hello World");

            Assert.IsNotNull(result);
            Assert.AreEqual(true, result.Value);
        }
        //[TestMethod]
        public async Task SimpleCallWithDataService()
        {
            DiSetup.RestDataServiceTests();
            DiSetup.InitializeRestEndpoints();

            this.startLocalServer();

            IDataService dataService = DiHelper.GetService <IDataService>(this.localServerUri, this.getHttpClientHandler());

            var result = await dataService.GetAllAsync <ValueObject <string> >("ValueStore");

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Count());
        }
Exemple #21
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);
            }
Exemple #22
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 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"));
            }
Exemple #25
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);
            }
            public void CreateOrUpdateAsyncCreateNewWithLists()
            {
                DiSetup.FileDataServiceTests();
                DiSetup.InitializeFileEndpoints();

                IDataService dataService = DiHelper.GetService <IDataService>(this.testPath);
                List <ValueObject <string> > stringList = new List <ValueObject <string> >()
                {
                    new ValueObject <string>("a"), new ValueObject <string>("b"), new ValueObject <string>("c")
                };

                bool result = dataService.CreateOrUpdateAsync <ValueObject <string> >("CreateOrUpdateAsyncTest4Action", stringList).GetAwaiter().GetResult();

                Assert.AreEqual(true, result);
            }
            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 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)));
            }
Exemple #29
0
            public void GetAllAsync()
            {
                DiSetup.InMemoryDataServiceTests();
                DiSetup.InitializeInMemoryEndpoints();
                IDataService dataService = DiHelper.GetService <IDataService>();

                dataService.CreateOrUpdateAsync <ValueObject <string> >("CreateOrUpdateAsyncTest2Action", new ValueObject <string>("TestString1")).GetAwaiter().GetResult();
                dataService.CreateOrUpdateAsync <ValueObject <string> >("CreateOrUpdateAsyncTest2Action", new ValueObject <string>("TestString2")).GetAwaiter().GetResult();
                dataService.CreateOrUpdateAsync <ValueObject <string> >("CreateOrUpdateAsyncTest2Action", new ValueObject <string>("TestString3")).GetAwaiter().GetResult();
                dataService.CreateOrUpdateAsync <ValueObject <string> >("CreateOrUpdateAsyncTest2Action", new ValueObject <string>("TestString4")).GetAwaiter().GetResult();

                var result = dataService.GetAllAsync <ValueObject <string> >("CreateOrUpdateAsyncTest2Action").GetAwaiter().GetResult();

                Assert.IsNotNull(result);
                Assert.AreEqual(4, result.Count());
            }
Exemple #30
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);
            }