public void Setup()
        {
            //Set up S's
            fakeConsoleOutput = Substitute.For <IConsoleOutput>();
            fakeFileOutput    = Substitute.For <IFileOutput>();

            //Set up X's
            airspace   = new Airspace(10000, 90000, 10000, 90000, 500, 20000);
            trackData1 = new TrackData("ABC123", 30000, 30000, 3000, "20181224200050123", 100, 45, fakeConsoleOutput);
            trackData2 = new TrackData("DEF123", 30001, 30001, 3001, "20181224200050123", 100, 45, fakeConsoleOutput);

            trackData3 = new TrackData("ABC123", 30000, 30000, 3000, "20181224200050123", 100, 45, fakeConsoleOutput);
            trackData4 = new TrackData("DEF123", 50000, 50000, 5000, "20181224200050123", 100, 45, fakeConsoleOutput);

            //Fake transponderReceiver
            fakeTransponderReceiver = Substitute.For <ITransponderReceiver>();

            //Create new ATM.TransponderReceiver for simulating inputs from the TransponderReceiver from the dll.
            transponderReceiver = new TransponderReceiver(fakeTransponderReceiver, fakeConsoleOutput);

            //Set up T's
            ATM = new ATMclass(fakeConsoleOutput, fakeFileOutput, airspace, fakeTransponderReceiver);

            //Attach ATM, so that updates to the transponderReceiver updates data in the ATM
            transponderReceiver.Attach(ATM);
        }
Пример #2
0
        public void AddTrackLeftEventFor(TrackData td, IFileOutput logger)
        {
            TrackLeftEvent tle = new TrackLeftEvent(td.TimeStamp, td, true, td.ConsoleOutput, logger);

            events.Add(tle);
            logger.Write(tle.FormatData());
        }
Пример #3
0
        public DownloadFileResult(IFileOutput fileOutput)
        {
            if (fileOutput == null)
            {
                throw new ArgumentNullException(nameof(fileOutput));
            }

            FileOutput = fileOutput;
        }
Пример #4
0
 public FileCombiner(IInput input, IMessage message, IFileReader fileReader, IFileOutput output, ISqlRunnerFacory sqlRunnerfactory, ISettingsService settingsService)
 {
     _input            = input;
     _message          = message;
     _fileReader       = fileReader;
     _output           = output;
     _sqlRunnerfactory = sqlRunnerfactory;
     _settingsService  = settingsService;
 }
Пример #5
0
 public void setup()
 {
     fakeFileOutput    = Substitute.For <IFileOutput>();
     fakeConsoleOutput = Substitute.For <IConsoleOutput>();
     timeStamp         = "235928121999";
     uut = new EventList();
     td1 = new TrackData("ABC123", 10000, 10000, 1000, timeStamp, 100, 45, fakeConsoleOutput);
     td2 = new TrackData("DEF123", 10000, 10000, 1000, timeStamp, 100, 45, fakeConsoleOutput);
     td3 = new TrackData("XYZ123", 10000, 10000, 1000, timeStamp, 100, 45, fakeConsoleOutput);
 }
Пример #6
0
        public void AddSeperationEventFor(TrackData td1, TrackData td2, IFileOutput logger)
        {
            List <TrackData> tracks = new List <TrackData>()
            {
                td1,
                td2
            };
            SeperationEvent se = new SeperationEvent(td1.TimeStamp, tracks, true, td1.ConsoleOutput, logger);

            events.Add(se);
            logger.Write(se.FormatData());
        }
        private void Persist_Report(string reportOutputDirectory,
                                    IFileOutput successContent)
        {
            Ensure_Directory(reportOutputDirectory);

            var reportPath = Path.Combine(reportOutputDirectory, $"{successContent.FileName}.pdf");

            Remove_Old_Report(reportPath);

            Write_Report(successContent, reportPath);

            return;
        }
 private void Write_Report(IFileOutput successContent,
                           string reportPath)
 {
     using (var stream = successContent.GetStream())
     {
         using (var memoryStream = new MemoryStream())
         {
             stream.CopyTo(memoryStream);
             var reportBytes = memoryStream.ToArray();
             File.WriteAllBytes(reportPath, reportBytes);
         }
     }
 }
        public void Setup()
        {
            //Setup stuff
            airspace      = new Airspace(xMin, xMax, yMin, yMax, zMin, zMax);
            fakeAirspace  = Substitute.For <IAirspace>();
            consoleOutput = Substitute.For <IConsoleOutput>();
            fileOutput    = Substitute.For <IFileOutput>();
            //Make new fake TransponderReceiver.
            transponderReceiver = Substitute.For <ITransponderReceiver>();;
            tracks = new List <TrackData>();


            uut = new ATMclass(consoleOutput, fileOutput, fakeAirspace, transponderReceiver);
        }
        public void setup()
        {
            //Setup stuff
            airspace       = new Airspace(xMin, xMax, yMin, yMax, zMin, zMax);
            fakeAirspace   = Substitute.For <IAirspace>();
            consoleOutput  = Substitute.For <IConsoleOutput>();
            fakeFileOutput = Substitute.For <IFileOutput>();
            //Make new fake TransponderReceiver.
            transponderReceiver = Substitute.For <ITransponderReceiver>();
            seperationEvents    = new List <Event>();
            tracks    = new List <TrackData>();
            timestamp = "235928121999";

            uut = new ATMclass(consoleOutput, fakeFileOutput, fakeAirspace, transponderReceiver);
        }
        public void setup()
        {
            //Set up S's
            fakeConsoleOutput = Substitute.For<IConsoleOutput>();
            fakeFileOutput = Substitute.For<IFileOutput>();
            fakeIntervalTimer = Substitute.For<IIntervalTimer>();
            fakeTransponderReceiver = Substitute.For<ITransponderReceiver>();

            //Set up X's
            airspace = new Airspace(10000, 90000, 10000, 90000, 500, 20000);

            //Set up T's
            atmClass = new ATMclass(fakeConsoleOutput, fakeFileOutput, airspace, fakeTransponderReceiver);

        }
Пример #12
0
        public ATMclass(IConsoleOutput outputConsole, IFileOutput outputFile, IAirspace airspace, ITransponderReceiver transponderReceiver)

        {
            _outputConsole       = outputConsole;
            _outputFile          = outputFile;
            _transponderReceiver = transponderReceiver;
            _airspace            = airspace;
            CurrentEvents        = new EventList();
            CurrentTracks        = new List <TrackData>();

            Timer = new System.Timers.Timer
            {
                Interval = 100
            };
            Timer.Elapsed  += TimerElapsed;
            Timer.AutoReset = true;
            Timer.Enabled   = true;
        }
Пример #13
0
        /// <summary>
        /// Reads the input stream and encodes it to the output stream.
        /// </summary>
        public void Encode(IFileInput input, IFileOutput output)
        {
            int symbol;

            // Getting the frequencies
            while ((symbol = input.ReadByte()) != -1)
            {
                _analyzer.ProcessSymbol(symbol);
            }

            long[] data    = _analyzer.GetAnalysis();
            Node   root    = _creator.CreateTree(data);
            var    encoder = new HuffmanEncoder(output, root);

            input.GoToStart();
            encoder.Encode(input);
            encoder.Finish();
        }
        public void setup()
        {
            fakeFileOutput    = Substitute.For <IFileOutput>();
            fakeConsoleOutput = Substitute.For <IConsoleOutput>();
            timeStamp         = "235928121999";
            td1 = new TrackData("ABC123", 10000, 10000, 1000, timeStamp, 100, 45, fakeConsoleOutput);
            td2 = new TrackData("DEF123", 10000, 10000, 1000, timeStamp, 100, 45, fakeConsoleOutput);
            td3 = new TrackData("XYZ123", 10000, 10000, 1000, timeStamp, 100, 45, fakeConsoleOutput);

            List <TrackData> tracks = new List <TrackData>()
            {
                td1,
                td2
            };

            uut_se  = new SeperationEvent(timeStamp, tracks, true, fakeConsoleOutput, fakeFileOutput);
            uut_tee = new TrackEnteredEvent(timeStamp, td1, true, fakeConsoleOutput, fakeFileOutput);
            uut_tle = new TrackLeftEvent(timeStamp, td1, true, fakeConsoleOutput, fakeFileOutput);
        }
Пример #15
0
        public void Setup()
        {
            //Set up S's
            fakeConsoleOutput = Substitute.For <IConsoleOutput>();
            fakeFileOutput    = Substitute.For <IFileOutput>();

            //Set up X's
            airspace   = new Airspace(10000, 90000, 10000, 90000, 500, 20000);
            trackData1 = new TrackData("ABC123", 30000, 30000, 3000, "20181224200050123", 100, 45, fakeConsoleOutput);
            trackData2 = new TrackData("DEF123", 30001, 30001, 3001, "20181224200050123", 100, 45, fakeConsoleOutput);

            trackData3 = new TrackData("ABC123", 30000, 30000, 3000, "20181224200050123", 100, 45, fakeConsoleOutput);
            trackData4 = new TrackData("DEF123", 50000, 50000, 5000, "20181224200050123", 100, 45, fakeConsoleOutput);

            //Fake transponderReceiver
            fakeTransponderReceiver = Substitute.For <ITransponderReceiver>();

            //Set up T's
            ATM = new ATMclass(fakeConsoleOutput, fakeFileOutput, airspace, fakeTransponderReceiver);
        }
Пример #16
0
        public void setup()
        {
            //Set up S's
            fakeConsoleOutput = Substitute.For<IConsoleOutput>();
            fakeFileOutput = Substitute.For<IFileOutput>();

            //Set up T's
            trackData1 = new TrackData("ABC123",10000,10000,1000,"201811071337000",42,10,fakeConsoleOutput);
            trackData1 = new TrackData("XYZ987", 10001, 10001, 1001, "201811071338000", 42, 10, fakeConsoleOutput);
            tracks = new List<TrackData>()
            {
                trackData1,
                trackData2
            };
            seperationEvent = new SeperationEvent("201811071337000",tracks,true, fakeConsoleOutput,fakeFileOutput);
            trackEnteredEvent = new TrackEnteredEvent(trackData1._TimeStamp,trackData1,true, fakeConsoleOutput, fakeFileOutput);
            trackLeftEvent = new TrackLeftEvent(trackData1._TimeStamp,trackData1,true, fakeConsoleOutput, fakeFileOutput);

            //Set up X's
        }
		public void Intialize()
		{
			_fileSystemHelper = Substitute.For<IFileSystemHelper>();
			_directory = Substitute.For<IDirectory>();
			_fileOutput = Substitute.For<IFileOutput>();
			_consoleOutput = Substitute.For<IConsoleOutput>();
			_utils = Substitute.For<IUtils>();
			_tagsOperation = Substitute.For<ITagsOperation>();
			_tagHelper = Substitute.For<ITagHelper>();
			_file = Substitute.For<IFile>();

			_target = new SearchOperation(
				_fileSystemHelper , 
				_directory, 
				_fileOutput, 
				_consoleOutput, 
				_file, 
				_utils, 
				_tagsOperation,
				_tagHelper);
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="SelfMediaDatabase.Core.Operations.Search.SearchOperation"/> class.
		/// </summary>
		/// <param name="fileSystemHelper">File system helper.</param>
		/// <param name="directory">Directory.</param>
		/// <param name="fileOutput">File output.</param>
		/// <param name="consoleOutput">Console output.</param>
		/// <param name="file">Injectable wrapper of <see cref="System.IO.File"/>.</param>
		/// <param name="utils">Some utils methods provider.</param>
		/// <param name="tagsOperation">Tags operation library.</param>
		/// <param name="tagHelper">Helper to access to tags of media files.</param>
		public SearchOperation(
			IFileSystemHelper fileSystemHelper, 
			IDirectory directory, 
			IFileOutput fileOutput, 
			IConsoleOutput consoleOutput, 
			IFile file, 
			IUtils utils,
			ITagsOperation tagsOperation,
			ITagHelper tagHelper)
		{
			if (fileSystemHelper == null)
				throw new ArgumentNullException("fileSystemHelper");
			if (directory == null)
				throw new ArgumentNullException("directory");
			if (fileOutput == null)
				throw new ArgumentNullException("fileOutput");
			if (consoleOutput == null)
				throw new ArgumentNullException("consoleOutput");
			if (file == null)
				throw new ArgumentNullException("file");
			if (utils == null)
				throw new ArgumentNullException("utils");
			if (tagsOperation == null)
				throw new ArgumentNullException("tagsOperation");
			if (tagHelper == null)
				throw new ArgumentNullException("exifHelper");

			_fileSystemHelper = fileSystemHelper;
			_directory = directory;
			_fileOutput = fileOutput;
			_consoleOutput = consoleOutput;
			_file = file;
			_utils = utils;
			_tagsOperation = tagsOperation;
			_tagHelper = tagHelper;
		}
Пример #19
0
            public PicklerObject(CodeContext/*!*/ context, object file, object protocol, object bin) {
                dispatchTable = new Dictionary<PythonType, PickleFunction>();
                dispatchTable[TypeCache.Boolean] = SaveBoolean;
                dispatchTable[TypeCache.Int32] = SaveInteger;
                dispatchTable[TypeCache.Null] = SaveNone;
                dispatchTable[TypeCache.Dict] = SaveDict;
                dispatchTable[TypeCache.BigInteger] = SaveLong;
                dispatchTable[TypeCache.Double] = SaveFloat;
                dispatchTable[TypeCache.String] = SaveUnicode;
                dispatchTable[TypeCache.PythonTuple] = SaveTuple;
                dispatchTable[TypeCache.List] = SaveList;
                dispatchTable[TypeCache.OldClass] = SaveGlobal;
                dispatchTable[TypeCache.Function] = SaveGlobal;
                dispatchTable[TypeCache.BuiltinFunction] = SaveGlobal;
                dispatchTable[TypeCache.PythonType] = SaveGlobal;
                dispatchTable[TypeCache.OldInstance] = SaveInstance;

                int intProtocol;
                if (file == null) {
                    _file = new PythonReadableFileOutput(context, new PythonStringIO.StringO());
                } else if (Converter.TryConvertToInt32(file, out intProtocol)) {
                    // For undocumented (yet tested in official CPython tests) list-based pickler, the
                    // user could do something like Pickler(1), which would create a protocol-1 pickler
                    // with an internal string output buffer (retrievable using GetValue()). For a little
                    // more info, see
                    // https://sourceforge.net/tracker/?func=detail&atid=105470&aid=939395&group_id=5470
                    _file = new PythonReadableFileOutput(context, new PythonStringIO.StringO());
                    protocol = file;
                } else if (file is IFileOutput) {
                    _file = (IFileOutput)file;
                } else {
                    _file = new PythonFileOutput(context, file);
                }

                this._memo = new PythonDictionary();

                if (protocol == null) protocol = PythonOps.IsTrue(bin) ? 1 : 0;

                intProtocol = PythonContext.GetContext(context).ConvertToInt32(protocol);
                if (intProtocol > highestProtocol) {
                    throw PythonOps.ValueError("pickle protocol {0} asked for; the highest available protocol is {1}", intProtocol, highestProtocol);
                } else if (intProtocol < 0) {
                    this._protocol = highestProtocol;
                } else {
                    this._protocol = intProtocol;
                }
            }
Пример #20
0
 public static Pickler Make(DynamicType cls,
     [DefaultParameterValue(null)] object file,
     [DefaultParameterValue(null)] object protocol,
     [DefaultParameterValue(null)] object bin
 )
 {
     if (cls == Ops.GetDynamicTypeFromClsOnlyType(typeof(Pickler))) {
         // For undocumented (yet tested in official CPython tests) list-based pickler, the
         // user could do something like Pickler(1), which would create a protocol-1 pickler
         // with an internal string output buffer (retrievable using GetValue()). For a little
         // more info, see
         // https://sourceforge.net/tracker/?func=detail&atid=105470&aid=939395&group_id=5470
         int intProtocol;
         if (file == null) {
             file = new PythonReadableFileOutput(new PythonStringIO.StringO());
         } else if (Converter.TryConvertToInt32(file, out intProtocol)) {
             return new Pickler((IFileOutput) new PythonReadableFileOutput(new PythonStringIO.StringO()), intProtocol, bin);
         }
         return new Pickler(file, protocol, bin);
     } else {
         Pickler pickler = cls.ctor.Call(cls, file, protocol, bin) as Pickler;
         if (pickler == null) throw Ops.TypeError("{0} is not a subclass of Pickler", cls);
         return pickler;
     }
 }
Пример #21
0
            public Pickler(IFileOutput file, object protocol, object bin)
            {
                dispatchTable = new Dictionary<DynamicType, PickleFunction>();
                dispatchTable[TypeCache.Boolean] = SaveBoolean;
                dispatchTable[TypeCache.Int32] = SaveInteger;
                dispatchTable[TypeCache.None] = SaveNone;
                dispatchTable[TypeCache.Dict] = SaveDict;
                dispatchTable[TypeCache.BigInteger] = SaveLong;
                dispatchTable[TypeCache.Double] = SaveFloat;
                dispatchTable[TypeCache.String] = SaveUnicode;
                dispatchTable[TypeCache.Tuple] = SaveTuple;
                dispatchTable[TypeCache.List] = SaveList;
                dispatchTable[TypeCache.OldClass] = SaveGlobal;
                dispatchTable[TypeCache.Function] = SaveGlobal;
                dispatchTable[TypeCache.BuiltinFunction] = SaveGlobal;
                dispatchTable[TypeCache.DynamicType] = SaveGlobal;
                dispatchTable[TypeCache.OldInstance] = SaveInstance;

                this.file = file;
                this.memo = new Dict();

                if (protocol == null) protocol = Ops.IsTrue(bin) ? 1 : 0;

                int intProtocol = Converter.ConvertToInt32(protocol);
                if (intProtocol > highestProtocol) {
                    throw Ops.ValueError("pickle protocol {0} asked for; the highest available protocol is {1}", intProtocol, highestProtocol);
                } else if (intProtocol < 0) {
                    this.protocol = highestProtocol;
                } else {
                    this.protocol = intProtocol;
                }
            }
Пример #22
0
        public SeperationEvent(string occurrenceTime, List <TrackData> involvedTracks, bool isRaised, IConsoleOutput outputConsole, IFileOutput outputFile) : base(outputFile, outputConsole)

        {
            base.occurrenceTime = occurrenceTime;
            InvolvedTracks      = involvedTracks;
            base.isRaised       = isRaised;
        }
Пример #23
0
        public TrackLeftEvent(string occurrenceTime, TrackData involvedTrack, bool isRaised, IConsoleOutput outputConsole, IFileOutput outputFile) : base(outputFile, outputConsole)
        {
            base.occurrenceTime = occurrenceTime;
            InvolvedTracks.Add(involvedTrack);
            base.isRaised = isRaised;

            ATM.IntervalTimer.IntervalTimer _timer = new ATM.IntervalTimer.IntervalTimer();
            _timer.Start(5000, this);
        }
Пример #24
0
 public FlightEvent(IFileOutput outputFile, IConsoleOutput outputConsole)
 {
     InvolvedTracks     = new List <TrackData>();
     this.outputFile    = outputFile;
     this.outputConsole = outputConsole;
 }
Пример #25
0
            public Pickler(CodeContext/*!*/ context, IFileOutput file, object protocol, object bin) {
                dispatchTable = new Dictionary<PythonType, PickleFunction>();
                dispatchTable[TypeCache.Boolean] = SaveBoolean;
                dispatchTable[TypeCache.Int32] = SaveInteger;
                dispatchTable[TypeCache.Null] = SaveNone;
                dispatchTable[TypeCache.Dict] = SaveDict;
                dispatchTable[TypeCache.BigInteger] = SaveLong;
                dispatchTable[TypeCache.Double] = SaveFloat;
                dispatchTable[TypeCache.String] = SaveUnicode;
                dispatchTable[TypeCache.PythonTuple] = SaveTuple;
                dispatchTable[TypeCache.List] = SaveList;
                dispatchTable[TypeCache.OldClass] = SaveGlobal;
                dispatchTable[TypeCache.Function] = SaveGlobal;
                dispatchTable[TypeCache.BuiltinFunction] = SaveGlobal;
                dispatchTable[TypeCache.PythonType] = SaveGlobal;
                dispatchTable[TypeCache.OldInstance] = SaveInstance;

                this._file = file;
                this._memo = new PythonDictionary();

                if (protocol == null) protocol = PythonOps.IsTrue(bin) ? 1 : 0;

                int intProtocol = PythonContext.GetContext(context).ConvertToInt32(protocol);
                if (intProtocol > highestProtocol) {
                    throw PythonOps.ValueError("pickle protocol {0} asked for; the highest available protocol is {1}", intProtocol, highestProtocol);
                } else if (intProtocol < 0) {
                    this._protocol = highestProtocol;
                } else {
                    this._protocol = intProtocol;
                }
            }
Пример #26
0
 public static TextWriter CreateText(this IFileOutput self, string path) => new StreamWriter(self.Create(path));
Пример #27
0
 public XmlTransformer(IFileInput input, IFileOutput output)
 {
     this.input  = input;
     this.output = output;
 }
 public void Respond(IFileOutput output)
 {
     _file = output;
 }
        private static void PublishOutput(List <DataModel> dataCollection, OutputFormat format)
        {
            IFileOutput myFormat = FileOutputFactory.GetMyFormatter(format);

            myFormat.GenerateOutput(dataCollection, "");
        }
Пример #30
0
 public HuffmanEncoder(IFileOutput output, Node huffmanTree)
 {
     _output = output;
     _tree   = huffmanTree;
 }