Пример #1
0
 public ConfigurationXml(IToastService toastService, ICanLoadAndSaveXml loadAndSave)
 {
     mToastService    = toastService ?? throw new ArgumentNullException(nameof(toastService));
     LoadAndSave      = loadAndSave ?? throw new ArgumentNullException(nameof(loadAndSave));
     mMutableChildren = new ObservableCollection <ModelBase>();
     Children         = new ReadOnlyObservableCollection <ModelBase>(mMutableChildren);
 }
        public void SetUp()
        {
            IConfigurationXml configFactory = new ConfigurationFactory(Substitute.For <IToastService>()).Create(Filename);

            const string sutFieldName = "LoadAndSave";

            mSut = (ICanLoadAndSaveXml)configFactory.GetType().GetField(sutFieldName, BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(configFactory);

            if (mSut == null)
            {
                Assert.Fail($"Unable to find private instance field '{sutFieldName}'");
            }

            mXmlDoc = Substitute.For <IXmlDocument>();

            IXmlDocumentFactory xmlDocFactory = Substitute.For <IXmlDocumentFactory>();

            xmlDocFactory.Create().Returns(mXmlDoc);

            SetSutField("mXmlDocFactory", xmlDocFactory);

            IFile file = Substitute.For <IFile>();

            file.Exists(Filename).Returns(ci => mFileExists);

            SetSutField("mFile", file);

            mXmlWriterFactory = Substitute.For <IXmlWriterFactory>();
            SetSutField("mXmlWriterFactory", mXmlWriterFactory);

            //Substitute fileStreamFactory to avoid disk access attempts
            IFileStreamFactory fileStreamFactory = Substitute.For <IFileStreamFactory>();

            SetSutField("mFileStreamFactory", fileStreamFactory);
        }
Пример #3
0
        public void SetUp()
        {
            mLoadAndSave = Substitute.For <ICanLoadAndSaveXml>();
            mLoadAndSave.Load().Returns(ci =>
            {
                IXmlDocument xmlDoc = new XmlDocumentWrap();
                xmlDoc.Load(GetTestConfigXml());
                return(xmlDoc);
            });

            mSut = new SaveIndication(Substitute.For <IToastService>(), mLoadAndSave);
        }
Пример #4
0
        public void SetUp()
        {
            mToastService = Substitute.For <IToastService>();

            mXmlDoc = new XmlDocumentWrap();
            mXmlDoc.Load(GetTestConfigXml());

            mLoadAndSave = Substitute.For <ICanLoadAndSaveXml>();
            mLoadAndSave.Load().Returns(mXmlDoc);

            mSut = new ConfigurationXml(mToastService,
                                        mLoadAndSave);
        }
 public SaveIndication(IToastService toastService, ICanLoadAndSaveXml loadAndSave)
     : base(toastService, loadAndSave)
 {
 }