예제 #1
0
        public UserConfigurationServiceTests()
        {
            m_httpClientFactoryMock = new Mock <IHttpClientFactory>();
            m_localStorageMock      = new Mock <ILocalStorage>();

            m_userConfigurationService = new UserConfigurationService(m_httpClientFactoryMock.Object, m_localStorageMock.Object);
        }
예제 #2
0
        public void UserConfigurationService_UnitTest_Constructor_InitializesProperties()
        {
            var filePath = Path.Combine(_testDir, Guid.NewGuid() + ".config");
            var service  = new UserConfigurationService(filePath);

            Assert.IsNotNull(service.Help, "Help property was not initialized by constructor.");
            Assert.IsNotNull(service.Help.IsCollapsed, "Help IsCollapsed property was not initialized by constructor.");
        }
예제 #3
0
        public void UserConfigurationService_UnitTest_HelpIsCollapsedWithoutType_ReturnsFalse()
        {
            var filePath = Path.Combine(_testDir, Guid.NewGuid() + ".config");


            var service = new UserConfigurationService(filePath);

            var type   = typeof(DsfActivity);
            var actual = service.Help.IsCollapsed[type];

            Assert.IsFalse(actual, "Help.IsCollapsed did not return false for a type not in the dictionary.");
        }
예제 #4
0
        public void UserConfigurationService_UnitTest_PersistenceDispose_FileWritten()
        {
            var filePath = Path.Combine(_testDir, Guid.NewGuid() + ".config");
            var service  = new UserConfigurationService(filePath);

            var exists = File.Exists(filePath);

            Assert.IsFalse(exists, "UserConfigurationService created file before test.");

            service.Dispose();
            exists = File.Exists(filePath);
            Assert.IsTrue(exists, "UserConfigurationService did not write file when disposed.");
        }
예제 #5
0
        public void UserConfigurationService_UnitTest_HelpIsCollapsedWithType_ReturnsStoredValue()
        {
            var filePath = Path.Combine(_testDir, Guid.NewGuid() + ".config");

            var service = new UserConfigurationService(filePath);

            Assert.IsNotNull(service.Help, "Help property was not initialized by constructor.");
            Assert.IsNotNull(service.Help.IsCollapsed, "Help IsCollapsed property was not initialized by constructor.");

            const bool Expected = true;

            var type = typeof(DsfActivity);

            service.Help.IsCollapsed[type] = Expected;

            var actual = service.Help.IsCollapsed[type];

            Assert.AreEqual(Expected, actual, "Help.IsCollapsed did not return the value stored for the type in the dictionary.");
        }
예제 #6
0
        public virtual IHttpActionResult UserConfigurationPut([FromBody] User_Configuration userConfigurations)
        {
            var result = new UserConfigurationService().PutUserConfigurations(UserId, userConfigurations);

            return(Ok(result));
        }
예제 #7
0
        public virtual IHttpActionResult UserConfigurationPost([FromBody] User_Configuration userConfigurations)
        {
            var result = new UserConfigurationService().PostUserConfigurations(UserId, userConfigurations);

            return(Created("", result));
        }
예제 #8
0
        public IHttpActionResult UserConfigurationGet()
        {
            var result = new UserConfigurationService().GetUserConfigurations(UserId);

            return(Ok(result));
        }
예제 #9
0
 public void UserConfigurationService_UnitTest_ConstructorWithNullFilePath_ThrowsArgumentNullException()
 {
     var service = new UserConfigurationService(null);
 }