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);
            }
Exemplo n.º 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);
                }
            }
Exemplo n.º 3
0
        public void Test1()
        {
            //sut
            //arrange
            IContainer container = DiSetup.InitDI();
            Customer   c         = container.Resolve <Customer>(); //new Customer(new CustomerRepo());

            c.FirstName = "Alfred";
            c.LastName  = "Obialo";
            c.Address   = "Nekede Owerri!";
            c.Id        = "alfredObialo";
            // act
            var res = c.CreateCustomer();

            _testOutputHelper.WriteLine(res.Message);
            _testOutputHelper.WriteLine(res.ExtraData.FirstName);
            // assert
            Assert.IsAssignableFrom <ICommandResult>(res);
            Assert.NotNull(res.ExtraData);
            Assert.IsAssignableFrom <IPersistableObj <Customer> >(c);
            Assert.IsType <Customer>(res.ExtraData);
            Assert.NotNull(c.DataSource);
            Assert.IsAssignableFrom <ICommandRepository <Customer> >(c.DataSource.CommandRepository);
            Assert.Equal(c, res.ExtraData);
            Assert.True(res.Success);
        }
Exemplo n.º 4
0
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     DiSetup.AdminApp();
     DiHelper.Register<INavigationPresenter, WpfNavigationPresenter>(Lifetime.Singleton);
     DiSetup.Initialize();
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting...");

            var container = DiSetup.GetContainer(new FileLogWriter("Jobs"));

            container.Setup(s => s.For <ISession>().Use <JobSession>());
            container.Setup(s => s.For <IDataRepository>().Use <ElsaJobRepo>());
            container.Setup(s => s.For <ElsaJobsScheduler>().Use <ElsaJobsScheduler>());

            var user     = ConfigurationManager.AppSettings["robotLogin"];
            var password = ConfigurationManager.AppSettings["robotPassword"];

            Console.WriteLine("Creating container...");

            using (var locator = container.GetLocator())
            {
                Console.WriteLine("Container created");

                var session = (locator.Get <ISession>() as JobSession);

                if (session == null)
                {
                    throw new InvalidOperationException("Cannot instatiate session");
                }

                session.Login(user, password);

                Console.WriteLine("Authenticated, starting scheduler");

                var scheduler = locator.Get <ElsaJobsScheduler>();
                scheduler.Start();
            }
        }
Exemplo n.º 6
0
            public void Resolve()
            {
                DiSetup.Tests();

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

                Assert.IsNotNull(client);
            }
Exemplo n.º 7
0
            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 IsNotNull()
            {
                DiSetup.FileDataServiceTests();

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

                Assert.IsNotNull(dataService);
                Assert.IsInstanceOfType(dataService, typeof(NET.efilnukefesin.Implementations.Services.DataService.FileDataService.FileDataService));
            }
            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);
            }
Exemplo n.º 11
0
        public FilesCalculatorViewModel()
        {
            DiSetup.Initialize();

            _fileDialogConfigurer = DiSetup.Container.Resolve <IFileDialogConfigurer>();

            FilesInfo = new List <FileInformation>();

            _calculatorService = DiSetup.Container.Resolve <ICalculatorService>();
        }
            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);
            }
Exemplo n.º 15
0
 public void Car_ShouldTurnOff()
 {
     // Arrange
     var container = DiSetup.Setup();
     var car = container.GetInstance<ICar>();
     car.TurnOffCar();
     //Act
     bool actual = car.IsOn;
     // Assert
     Assert.False(actual);
 }
Exemplo n.º 16
0
        public void Motor_ShouldReturnRPM()
        {
            // Arrange
            var container = DiSetup.Setup();
            var motor     = container.GetInstance <IMotor>();
            // Act
            var expected = 1000;
            var actual   = motor.GetRPM();

            // Assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 17
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>));
            }
            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)));
            }
Exemplo n.º 20
0
 public void Car_ShouldStart()
 {
     // Arrange
     var container = DiSetup.Setup();
     var car = container.GetInstance<ICar>();
     car.StartCar();
     // Act
     bool expected = true;
     bool actual = car.IsOn;
     // Assert 
     Assert.Equal(expected, actual);
 }
            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);
            }
            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);
            }
Exemplo n.º 23
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);
        }
Exemplo n.º 26
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);
            }
Exemplo n.º 27
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);
            }
        //[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());
        }
Exemplo n.º 29
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);
            }