コード例 #1
0
        public void GetWithProvidedIdReturnsNullWhenNoMatchingConfigurationExists()
        {
            var locatorMock = MockRepository.GenerateMock<IConfigurationResourceLocator>();
            locatorMock.Stub(x => x.Locate(Arg<string>.Is.Anything)).Return(new IConfigurationElement[] { });
            var repository = new ConfigurationRepository(locatorMock);
            var value = repository.Get(0);

            Assert.IsNull(value);
        }
コード例 #2
0
 public void GetsConfigurationWhenMatchingConfigurationExists()
 {
     int elementId = 0;
     var configElementMock = MockRepository.GenerateMock<IRootConfigurationElement>();
     configElementMock.Id = elementId;
     var locatorMock = MockRepository.GenerateMock<IConfigurationResourceLocator>();
     locatorMock.Stub(x => x.Locate(elementId.ToString())).Return(new [] { configElementMock });
     var repository = new ConfigurationRepository(locatorMock);
     var value = repository.Get(elementId);
     Assert.IsNotNull(value);
 }