Beispiel #1
0
        public ManageControllerTests()
        {
            ApplicationTime.Set(new DateTime(2021, 1, 1));

            _bookableHandler  = Substitute.For <IBookableHandler>();
            _manageController = new ManageController(_bookableHandler);
        }
Beispiel #2
0
        public override void Update(ApplicationTime time)
        {
            var timer = time.TotalMilliseconds / (3600);

            Camera.Update();
            light.Direction.X = -14.0f + MathF.Abs(MathF.Sin(MathUtil.Radians(timer * 360.0f)) * 2.0f);
            light.Direction.X = 0.0f + MathF.Sin(MathUtil.Radians(timer * 360.0f)) * MathF.Cos(MathUtil.Radians(timer * 360.0f)) * 2.0f;
            light.Direction.Y = 0.0f + MathF.Sin(MathUtil.Radians(timer * 360.0f)) * 2.0f;
            light.Direction.Z = 0.0f + MathF.Cos(MathUtil.Radians(timer * 360.0f)) * 2.0f;

            ConstBuffer2.SetData(ref light);


            uniform.Update(Camera);
            ConstBuffer.SetData(ref uniform);


            Sphere.Rotation  = new(yaw, -yaw, yaw);
            Torus.Rotation   = new(-yaw, yaw, -yaw);
            Pyramid.Rotation = new(-yaw, -yaw, yaw);
            Cube.Rotation    = new(yaw, -yaw, -yaw);
            Capsule.Rotation = new(-yaw, yaw, -yaw);


            yaw = timer;
        }
        When_CurrentTimeProvider_is_accessed_after_ClearLogic_is_called_Then_time_provider_is_set_to_default_logic()
        {
            ApplicationTime.ResetToDefault();
            ApplicationTime.ClearLogic();

            Assert.IsInstanceOf <DefaultTimeProvider>(ApplicationTime.CurrentTimeProvider);
        }
Beispiel #4
0
        public override void Draw(ApplicationTime time)
        {
            Device.WaitIdle();
            CommandBuffer commandBuffer = Context.CommandBuffer;

            commandBuffer.Begin();


            commandBuffer.BeginFramebuffer(Framebuffer);
            commandBuffer.SetScissor(Window.FramebufferSize.Width, Window.FramebufferSize.Height, 0, 0);
            commandBuffer.SetViewport(Window.FramebufferSize.Width, Window.FramebufferSize.Height, 0, 0);

            commandBuffer.SetGraphicPipeline(PipelineState);
            commandBuffer.BindDescriptorSets(DescriptorSet);

            commandBuffer.SetVertexBuffers(new[] { GLTFModel.VertexBuffer });
            commandBuffer.SetIndexBuffer(GLTFModel.IndexBuffer, 0, GLTFModel.IndexType);


            foreach (Scene sc in GLTFModel.Scenes)
            {
                foreach (Node node in sc.Root.Children)
                {
                    RenderNode(commandBuffer, node, sc.Root.LocalMatrix);
                }
            }


            commandBuffer.Close();
            Device.Submit(commandBuffer);
            SwapChain.Present();
        }
Beispiel #5
0
        public override void Draw(ApplicationTime time)
        {
            Device.WaitIdle();
            CommandBuffer cmd = Context.CommandBuffer;

            cmd.Begin();
            cmd.BeginFramebuffer(Framebuffer);
            cmd.SetScissor(Window.FramebufferSize.Width, Window.FramebufferSize.Height, 0, 0);
            cmd.SetViewport(Window.FramebufferSize.Width, Window.FramebufferSize.Height, 0, 0);


            cmd.BindDescriptorSets(DescriptorSet_0);
            cmd.SetGraphicPipeline(PipelineState_0);
            GLTFModel.Draw(cmd, PipelineState_0);


            cmd.BindDescriptorSets(DescriptorSet_1);
            cmd.SetGraphicPipeline(PipelineState_1);
            GLTFModel.Draw(cmd, PipelineState_1);


            cmd.BindDescriptorSets(DescriptorSet_2);
            cmd.SetGraphicPipeline(PipelineState_2);
            GLTFModel.Draw(cmd, PipelineState_2);


            cmd.Close();
            Device.Submit(cmd);
            SwapChain.Present();
        }
Beispiel #6
0
        public override void Draw(ApplicationTime time)
        {
            Device.WaitIdle();

            cmd_compute.Begin();
            cmd_compute.SetComputePipeline(PipelineState_1);
            cmd_compute.BindDescriptorSets(DescriptorSet_1);

            cmd_compute.Dispatch2D(Window.FramebufferSize.Width, Window.FramebufferSize.Height, 8, 8);

            cmd_compute.Close();
            Device.Submit(cmd_compute);
            Device.ComputeQueueWaitIdle();


            CommandBuffer cmd = Context.CommandBuffer;

            cmd.Begin();
            cmd.BeginFramebuffer(Framebuffer);
            cmd.SetScissor(Window.FramebufferSize.Width, Window.FramebufferSize.Height, 0, 0);
            cmd.SetViewport(Window.FramebufferSize.Width, Window.FramebufferSize.Height, 0, 0);


            cmd.BindDescriptorSets(DescriptorSet_0);
            cmd.SetGraphicPipeline(PipelineState_0);
            cmd.Draw(3, 1, 0, 0);


            cmd.Close();
            Device.Submit(cmd);
            SwapChain.Present();
        }
Beispiel #7
0
        public override void Update(ApplicationTime time)
        {
            if (mod_r == 0)
            {
                mod_r = mod_g = mod_b += 20;
            }
            //Update the colors of our scene
            r += mod_r * 0.00005f;
            g += mod_g * 0.00002f;
            b += mod_b * 0.00001f;

            if (r >= 1.0f || r <= 0.0f)
            {
                mod_r *= -1;
            }

            if (g >= 1.0f || g <= 0.0f)
            {
                mod_g *= -1;
            }

            if (b >= 1.0f || b <= 0.0f)
            {
                mod_b *= -1;
            }
        }
        public void When_ResetToDefault_is_called_Then_logic_is_set_to_default_logic()
        {
            ApplicationTime.CurrentTimeProvider = new Mock <ITimeProvider>().Object;
            ApplicationTime.ResetToDefault();
            var logic = ApplicationTime.CurrentTimeProvider;

            Assert.IsInstanceOf <DefaultTimeProvider>(logic);
        }
Beispiel #9
0
        public override void Update(ApplicationTime time)
        {
            Model = Matrix4x4.CreateFromYawPitchRoll(yaw, pitch, roll) * Matrix4x4.CreateTranslation(0.0f, .0f, 0.0f);
            uniform.Update(Camera, Model);
            ConstBuffer.SetData(ref uniform);

            yaw += 0.0006f * MathF.PI;
        }
        public void When_GetUtcNow_is_called_Then_GetUtcNow_of_time_provider_is_called()
        {
            var timeProviderMock = new Mock <ITimeProvider>();

            ApplicationTime.CurrentTimeProvider = timeProviderMock.Object;

            ApplicationTime.GetUtcNow();

            timeProviderMock.Verify(mock => mock.GetUtcNow());
        }
Beispiel #11
0
        internal Application()
        {
            var platformTypeAttribute = ReflectionHelper.GetAttribute <PlatformTypeAttribute>(GetType());

            if (!ReflectionHelper.IsTypeDerived(platformTypeAttribute.PlatformType, typeof(ApplicationPlatform)))
            {
                throw new InvalidOperationException("PlatformType must be derived from ApplicationPlatform.");
            }

            services                 = new ServiceRegistry();
            appTime                  = new ApplicationTime();
            totalTime                = new TimeSpan();
            timer                    = new TimerTick();
            IsFixedTimeStep          = false;
            maximumElapsedTime       = TimeSpan.FromMilliseconds(500.0);
            TargetElapsedTime        = TimeSpan.FromTicks(10000000 / 120); // target elapsed time is by default 60Hz
            lastUpdateCount          = new int[4];
            nextLastUpdateCountIndex = 0;

            // Calculate the updateCountAverageSlowLimit (assuming moving average is >=3 )
            // Example for a moving average of 4:
            // updateCountAverageSlowLimit = (2 * 2 + (4 - 2)) / 4 = 1.5f
            const int BadUpdateCountTime = 2; // number of bad frame (a bad frame is a frame that has at least 2 updates)
            var       maxLastCount       = 2 * Math.Min(BadUpdateCountTime, lastUpdateCount.Length);

            updateCountAverageSlowLimit = (float)(maxLastCount + (lastUpdateCount.Length - maxLastCount)) / lastUpdateCount.Length;

            services.AddService(typeof(IWindowService), this);
            services.AddService(typeof(ITimeService), appTime);

            // Setup Content Manager
            contentManager = new ContentManager(services);
            contentManager.AddMapping(AssetType.EngineReferences, typeof(EngineReferenceCollection));
            contentManager.AddMapping(AssetType.Model, typeof(Model));
            contentManager.AddMapping(AssetType.Effect, typeof(ShaderCollection));
            contentManager.AddMapping(AssetType.Texture2D, typeof(Texture2D));
            contentManager.AddMapping(AssetType.TextureCube, typeof(TextureCube));
            contentManager.AddMapping(AssetType.Cutscene, typeof(Cutscene));

            var additionalServices = ReflectionHelper.GetAttributes <RequiredServiceAttribute>(GetType());

            foreach (var requiredService in additionalServices)
            {
                var service = Activator.CreateInstance(requiredService.ClassType, services);
                services.AddService(requiredService.ServiceType, service);
            }

            // Setup Platform
            applicationPlatform                = (ApplicationPlatform)Activator.CreateInstance(platformTypeAttribute.PlatformType, this);
            applicationPlatform.Activated     += ApplicationPlatformActivated;
            applicationPlatform.Deactivated   += ApplicationPlatformDeactivated;
            applicationPlatform.Exiting       += ApplicationPlatform_Exiting;
            applicationPlatform.WindowCreated += ApplicationPlatformWindowCreated;
        }
        public void sets_current_time_as_lastUpdated_in_result_feed_properties()
        {
            var now = new DateTime(2012, 2, 15);

            ApplicationTime._replaceCurrentTimeLogic(() => now);

            var result = execute();

            ApplicationTime._revertToDefaultLogic();

            Assert.Equal(now, result.LastUpdatedTime);
        }
Beispiel #13
0
        public override void Draw(ApplicationTime time)
        {
            Device.WaitIdle();

            CommandBuffer.Begin();
            CommandBuffer.BeginFramebuffer(Framebuffer, r, g, b, 1);

            CommandBuffer.Close();
            Device.Submit(CommandBuffer);

            SwapChain.Present();
        }
 public void OnGet()
 {
     ApplicationTime = _cache?.Get <DateTime>("DateTime");
     if (ApplicationTime == null || ApplicationTime.Equals(default(DateTime)))
     {
         IsCacheEnabled  = false;
         ApplicationTime = DateTime.Now;
     }
     else
     {
         IsCacheEnabled = true;
     }
 }
Beispiel #15
0
 public static Bookable MapToBookable(BookableCreateRequest request)
 {
     return(new()
     {
         Id = Guid.Empty,
         Name = request.Name,
         From = request.From ?? ApplicationTime.UtcNow(),
         To = request.To ?? DateTime.MaxValue,
         Foresight = request.Foresight,
         StartInterval = request.StartInterval,
         DaysAndTimes = request.DaysAndTimes,
         NonBookableDays = request.NonBookableDays,
     });
 }
Beispiel #16
0
 public async Task CreateBookable_NormalRollingBookableValidData_ShouldCallHandler()
 {
     Bookable expectedBookable = new()
     {
         Id           = Guid.Empty,
         Name         = "Test name",
         From         = ApplicationTime.UtcNow(),
         To           = DateTime.MaxValue,
         DaysAndTimes = new List <DayAndTimes>()
         {
             new()
             {
                 Day  = DayOfWeek.Monday,
                 Time = new FromToTime
                 {
                     From = new Time
                     {
                         Hour   = 10,
                         Minute = 0,
                     },
                     To = new Time
                     {
                         Hour   = 18,
                         Minute = 0,
                     },
                 },
                 NonBookableTime = new FromToTime
                 {
                     From = new Time
                     {
                         Hour   = 13,
                         Minute = 0,
                     },
                     To = new Time
                     {
                         Hour   = 13,
                         Minute = 30,
                     },
                 }
             },
         },
         Foresight       = 24,
         StartInterval   = StartInterval.Fifteen,
         NonBookableDays = null,
     };
Beispiel #17
0
        public MiniUIApplication()
        {
            var services = new ServiceRegistry();
            // Needs to be declared before the D3D device manager as it hooks to
            // the D3D device creation event
            var d2dDeviceManager = new Direct2DDeviceManager(services);

            d3dDeviceManager = ToDispose(new SimpleDeviceManager(services)
            {
                HorizontalDpi             = 96.0f,
                VerticalDpi               = 96.0f,
                PreferredBackBufferWidth  = 1280,
                PreferredBackBufferHeight = 720,
                PreferredBackBufferFormat = Format.R8G8B8A8_UNorm,
                IsFullScreen              = false,
                IsStereo = false,
                PreferredGraphicsProfile  = new[] { FeatureLevel.Level_11_0, },
                PreferredMultiSampleCount = 1
            });
            form = new RenderForm("OdysseyUI Test")
            {
                ClientSize = new Size(d3dDeviceManager.PreferredBackBufferWidth, d3dDeviceManager.PreferredBackBufferHeight),
            };

            d3dDeviceManager.CreateDevice(form.Handle, DeviceCreationFlags.Debug | DeviceCreationFlags.BgraSupport);

            var content      = new ContentManager(services);
            var styleManager = new StyleManager(services);

            uiManager       = new DesktopUserInterfaceManager(services);
            applicationTime = new ApplicationTime();
            timerTick       = new TimerTick();

            services.AddService(typeof(IStyleService), styleManager);
            services.AddService(typeof(IUserInterfaceState), uiManager);
            services.AddService(typeof(IWindowService), this);
            services.AddService(typeof(IDirect2DService), d2dDeviceManager);

            content.LoadAssetList("Assets/Assets.yaml");

            overlay = ToDispose(SampleOverlay.New(services));
            uiManager.Initialize();
            uiManager.CurrentOverlay = overlay;
        }
Beispiel #18
0
        public override void Update(ApplicationTime time)
        {
            var timer = time.TotalMilliseconds / (3600);

            Camera.Update();
            //light.LightDirection.X = -14.0f + MathF.Abs(MathF.Sin(MathUtil.Radians(timer * 360.0f)) * 2.0f);
            light.LightDirection.X = 0.0f + MathF.Sin(MathUtil.Radians(timer * 360.0f)) * MathF.Cos(MathUtil.Radians(timer * 360.0f)) * 2.0f;
            light.LightDirection.Y = 0.0f + MathF.Sin(MathUtil.Radians(timer * 360.0f)) * 2.0f;
            light.LightDirection.Z = 0.0f + MathF.Cos(MathUtil.Radians(timer * 360.0f)) * 2.0f;



            ConstBuffer4.SetData(ref light);


            Model = Matrix4x4.CreateFromYawPitchRoll(yaw, pitch, roll) * Matrix4x4.CreateTranslation(11.0f, .3f, 0.0f);
            uniform.Update(Camera, Model);
            ConstBuffer.SetData(ref uniform);

            Model = Matrix4x4.CreateFromYawPitchRoll(-yaw, pitch, roll) * Matrix4x4.CreateTranslation(0, 1.0f, 0.0f);
            uniform.Update(Camera, Model);
            ConstBuffer2.SetData(ref uniform);

            Model = Matrix4x4.CreateFromYawPitchRoll(yaw, pitch, roll) * Matrix4x4.CreateTranslation(-11.0f, .3f, 0.0f);
            uniform.Update(Camera, Model);
            ConstBuffer3.SetData(ref uniform);

            if (Input.Keyboards[0].IsKeyPressed(Key.T))
            {
                if (light.IsTexture == 1)
                {
                    light.IsTexture = 0;
                }

                else if (light.IsTexture == 0)
                {
                    light.IsTexture = 1;
                }
            }
        }
Beispiel #19
0
        public override void Update(ApplicationTime time)
        {
            var timer = time.TotalMilliseconds / (3600);

            Camera.Update();
            light.Direction.X = -14.0f + MathF.Abs(MathF.Sin(MathUtil.Radians(timer * 360.0f)) * 2.0f);
            light.Direction.X = 0.0f + MathF.Sin(MathUtil.Radians(timer * 360.0f)) * MathF.Cos(MathUtil.Radians(timer * 360.0f)) * 2.0f;
            light.Direction.Y = 0.0f + MathF.Sin(MathUtil.Radians(timer * 360.0f)) * 2.0f;
            light.Direction.Z = 0.0f + MathF.Cos(MathUtil.Radians(timer * 360.0f)) * 2.0f;



            ConstBuffer2.SetData(ref light);


            Model = Matrix4x4.CreateFromYawPitchRoll(yaw, pitch, roll) * Matrix4x4.CreateTranslation(0.0f, .0f, 0.0f);
            uniform.Update(Camera, Model);
            ConstBuffer.SetData(ref uniform);



            yaw = timer;
        }
        public void updates_cache_with_new_feed_content()
        {
            var now = new DateTime(2012, 2, 20);

            ApplicationTime._replaceCurrentTimeLogic(() => now);

            var cached = new LocalFeedInfo()
            {
                Url       = "http://cached.feed/rss",
                Content   = "cached-content",
                Etag      = "cached-etag",
                LastFetch = new DateTime(2012, 2, 3)
            };

            _feedsProvider.Db().LocalFeedInfo.Insert(cached);

            var newFeed = prepare_fake_feed();

            A.CallTo(
                () => _remoteData.ReadRemoteSource(
                    A <LocalFeedInfo> .That.Matches(x => x.Url == cached.Url && x.Etag == cached.Etag && x.LastFetch == cached.LastFetch)
                    )
                )
            .Returns(new RemoteContentResponse(true, "new-etag", newFeed, HttpStatusCode.OK));

            execute(cached.Url);

            List <LocalFeedInfo> fromDb = _feedsProvider.Db().LocalFeedInfo.All().ToList <LocalFeedInfo>();

            Assert.Equal(1, fromDb.Count);

            Assert.Equal(cached.Url, fromDb[0].Url);
            Assert.Equal(newFeed.GetRssString(), fromDb[0].Content);
            Assert.Equal("new-etag", fromDb[0].Etag);
            Assert.Equal(now, fromDb[0].LastFetch);
        }
Beispiel #21
0
 public TimeOverride(DateTime newDate)
 {
     ApplicationTime.ReplaceCurrentTimeLogic(() => newDate);
 }
Beispiel #22
0
 public void Dispose()
 {
     ApplicationTime.RevertToDefaultLogic();
 }
        public void When_GetUtcNow_is_called_for_the_first_time_Then_no_exception_is_thrown()
        {
            ApplicationTime.ClearLogic();

            Assert.DoesNotThrow(() => ApplicationTime.GetUtcNow());
        }
Beispiel #24
0
 public virtual void Update(ApplicationTime time)
 {
 }
Beispiel #25
0
 public virtual void Draw(ApplicationTime time)
 {
 }
Beispiel #26
0
 public override void Update(ApplicationTime time)
 {
 }