コード例 #1
0
        public void Handle_WrongStatementType_ThrowsException()
        {
            MockRepository mocks = new MockRepository();
              IBlacklistManager blacklistManager = mocks.Stub<IBlacklistManager>();
              BlockParserContext blockParserContext = new BlockParserContext (
              new ProblemPipeStub(),
              Fragment.CreateNamed ("returnFragmentType"),
              new List<ReturnCondition>(),
              blacklistManager,
              delegate { });

              StatementHandlerBase<AssignmentStatement> handler = new AssignmentStatementHandlerController (blockParserContext);
              Method sampleMethod = IntrospectionUtility.MethodFactory<StatementHandlerBaseSample> ("ContainsReturnStatement");
              Block sampleBlock = (Block) sampleMethod.Body.Statements[1];
              Statement sample = sampleBlock.Statements[0];

              ISymbolTable symbolTable = mocks.Stub<ISymbolTable>();
              HandleContext context = new HandleContext (
              sample,
              symbolTable,
              new List<IPreCondition>(),
              new List<string>(),
              new List<BlockAssignment>(),
              new List<int>(),
              new Dictionary<string, bool>(),
              new Dictionary<string, bool>());
              handler.Handle (context);
        }
コード例 #2
0
        public void AcksOnDelivery()
        {
            var mockRepository = new MockRepository();
            var rabbitModel = mockRepository.DynamicMock<IModel>();
            var messageSerializer = mockRepository.DynamicMock<IMessageSerializer>();
            var registeredConsumer = mockRepository.DynamicMock<IRegisteredConsumer>();
            var properties = mockRepository.Stub<IBasicProperties>();
            var config = mockRepository.DynamicMock<IBrokerConfiguration>();

            using (mockRepository.Record())
            {
                SetupResult.For(registeredConsumer.MessageType).Return(typeof (TestMessage));
                SetupResult.For(registeredConsumer.Queue).Return("q");
                SetupResult.For(registeredConsumer.ConsumerType).Return(typeof (TestConsumer));
                SetupResult.For(messageSerializer.DeserializeMessage(null)).IgnoreArguments().Return(
                    mockRepository.Stub<IMessageEnvelope<TestMessage>>());
                SetupResult.For(config.PipelineEvents).Return(new PipelineEvents());
                Expect.Call(() => rabbitModel.BasicAck(1, false));
            }

            using (mockRepository.Playback())
            {
                var callbackConsumer = new GroupedCallbackConsumer(rabbitModel, messageSerializer, config);
                callbackConsumer.ConsumeQueue(registeredConsumer);
                callbackConsumer.QueueConsumers["q"].Consumer.HandleBasicDeliver("ct1", 1, false, "ex", typeof(TestMessage).ToRoutingKey(), properties, new byte[0]);

                callbackConsumer.Close();
                callbackConsumer.Dispose();
            }
        }
コード例 #3
0
        public void ShouldQuoteAndHtmlEncodeCsvItemsContainingComma()
        {
            var mocks = new MockRepository();

            var httpRequestFactoryStub = mocks.Stub<IHttpRequestFactory>();
            var requestStub = mocks.Stub<IHttpRequest>();
            var responseStub = mocks.Stub<IHttpResponse>();

            var stream = new MemoryStream();

            using(mocks.Record())
            {
                SetupResult.For(httpRequestFactoryStub.Create(null)).IgnoreArguments().Return(requestStub);
                SetupResult.For(requestStub.GetRequestStream()).Return(stream);
                SetupResult.For(requestStub.GetResponse()).Return(responseStub);
            }

            var comm = new WebCommunication(httpRequestFactoryStub);

            comm.PostCsv("http://test.com",WorkItem.New("1","/").UpdateProperty("title","title,with,comma"));

            using(var reader = new StreamReader(new MemoryStream(stream.ToArray())))
            {
                var actual = reader.ReadToEnd();

                Assert.AreEqual("id=1,\"title=title,with,comma\"",actual);
            }
        }
コード例 #4
0
ファイル: AmigaOSPlatformTests.cs プロジェクト: relaxar/reko
 public void Setup()
 {
     this.mr = new MockRepository();
     this.fsSvc = mr.StrictMock<IFileSystemService>();
     this.tllSvc = mr.Stub<ITypeLibraryLoaderService>();
     this.services = mr.StrictMock<IServiceProvider>();
     var cfgSvc = mr.Stub<IConfigurationService>();
     var env = mr.Stub<OperatingEnvironment>();
     this.arch = new M68kArchitecture();
     this.rtls = new List<RtlInstruction>();
     this.m = new RtlEmitter(rtls);
     cfgSvc.Stub(c => c.GetEnvironment("amigaOS")).Return(env);
     env.Stub(e => e.TypeLibraries).Return(new List<ITypeLibraryElement>());
     env.Stub(e => e.CharacteristicsLibraries).Return(new List<ITypeLibraryElement>());
     env.Stub(e => e.Options).Return(new Dictionary<string, object>
     {
         { "versionDependentLibraries", new Dictionary<string,object>
             {
                 { "33", new List<object> { "exec_v33", "dos_v33" } },
                 { "34", new List<object> { "exec_v34", "dos_v34" } },
             }
         }
     });
     this.services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(cfgSvc);
     this.services.Stub(s => s.GetService(typeof(IFileSystemService))).Return(fsSvc);
     this.services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tllSvc);
     this.frame = new Frame(arch.FramePointerType);
 }
コード例 #5
0
ファイル: HBaseTableTests.cs プロジェクト: nordbergm/HBaseNet
        public void ReturnsRow()
        {
            MockRepository mockRepository = new MockRepository();
            IHBaseConnection connection = mockRepository.Stub<IHBaseConnection>();
            IHBaseRowData rowData = mockRepository.Stub<IHBaseRowData>();

            byte[] rowName = Encoding.UTF8.GetBytes("r");
            byte[] tableName = Encoding.UTF8.GetBytes("t");

            using (mockRepository.Record())
            {
                SetupResult.For(
                    connection
                        .GetRow(
                            tableName,
                            rowName))
                        .Return(rowData);
                SetupResult.For(rowData.Columns).Return(new Dictionary<byte[], IList<IHBaseCellData>>());
                SetupResult.For(rowData.Key).Return(rowName);
            }

            using (mockRepository.Playback())
            {
                HBaseDatabase db = new HBaseDatabase(connection);
                HBaseTable table = new HBaseTable(tableName, db);

                var row = table.GetRow(rowName);

                Assert.Equal(rowName, row.Key);
            }
        }
コード例 #6
0
 public void Setup()
 {
     this.tabCtrl = new TabControl();
     this.mr = new MockRepository();
     this.pane = mr.Stub<IWindowPane>();
     this.services = mr.Stub<IServiceProvider>();
 }
コード例 #7
0
ファイル: PhoneNumbersTests.cs プロジェクト: HomeSen/Helpers
        public void FormatPhoneNumber_PhoneNumberInDresdenGermany_ReturnsFormattedNumber(
            [Values(DISTANCE_RULE.CANONICAL, DISTANCE_RULE.InternationalRule, DISTANCE_RULE.LongDistanceRule,
                DISTANCE_RULE.SameAreaRule)] DISTANCE_RULE distanceRule,
            [Values("+49 (351) 1234567", "00493511234567", "03511234567", "1234567")] string expected)
        {
            MockRepository mocks = new MockRepository();
            IPhoneNumberDataXml xmlDataProvider = mocks.Stub<IPhoneNumberDataXml>();
            IPhoneNumberDataRegistry registryDataProvider = mocks.Stub<IPhoneNumberDataRegistry>();

            string number = "+493511234567";

            using (mocks.Record())
            {
                registryDataProvider.GetUserCountryID();
                LastCall.Return("49");
                registryDataProvider.GetUserAreaCode();
                LastCall.Return("351");
                registryDataProvider.GetPhoneFormat(49, DISTANCE_RULE.InternationalRule);
                LastCall.Return("00EFG");
                registryDataProvider.GetPhoneFormat(49, DISTANCE_RULE.LongDistanceRule);
                LastCall.Return("0FG");
                registryDataProvider.GetPhoneFormat(49, DISTANCE_RULE.SameAreaRule);
                LastCall.Return("G");

                xmlDataProvider.GetCountryCode("4935");
                LastCall.Return("49");
                xmlDataProvider.GetAreaCode("+493511234567");
                LastCall.Return("+49351");
            }

            PhoneNumbers phoneNumberConverter = new PhoneNumbers(xmlDataProvider, registryDataProvider);
            string actual = phoneNumberConverter.FormatPhoneNumber(number, distanceRule);

            Assert.AreEqual(expected, actual);
        }
コード例 #8
0
 public void SetUp()
 {
     mock=new MockRepository();
     dataWriter = mock.DynamicMock<IDataWriter>();
     dataReader = mock.Stub<IDataReader>();
     randomSecret = mock.Stub<IRandomSecret>();
 }
コード例 #9
0
ファイル: BlockWorkitemTests.cs プロジェクト: relaxar/reko
 public void Setup()
 {
     mr = new MockRepository();
     program = new Program();
     proc = new Procedure("testProc", new Frame(PrimitiveType.Word32));
     block = proc.AddBlock("l00100000");
     trace = new RtlTrace(0x00100000);
     r0 = new Identifier("r0", PrimitiveType.Word32, new RegisterStorage("r0", 0, 0, PrimitiveType.Word32));
     r1 = new Identifier("r1", PrimitiveType.Word32, new RegisterStorage("r1", 1, 0, PrimitiveType.Word32));
     r2 = new Identifier("r2", PrimitiveType.Word32, new RegisterStorage("r2", 2, 0, PrimitiveType.Word32));
     sp = new Identifier("sp", PrimitiveType.Word32, new RegisterStorage("sp", 15, 0, PrimitiveType.Word32));
     grf = proc.Frame.EnsureFlagGroup(Registers.eflags, 3, "SCZ", PrimitiveType.Byte);
     var sc = new ServiceContainer();
     var listener = mr.Stub<DecompilerEventListener>();
     scanner = mr.StrictMock<IScanner>();
     arch = mr.Stub<IProcessorArchitecture>();
     program.Architecture = arch;
     program.SegmentMap = new SegmentMap(
         Address.Ptr32(0x00100000),
         new ImageSegment(
             ".text",
             new MemoryArea(Address.Ptr32(0x00100000), new byte[0x20000]),
             AccessMode.ReadExecute));
     arch.Replay();
     program.Platform = new DefaultPlatform(null, arch);
     arch.BackToRecord();
     arch.Stub(s => s.StackRegister).Return((RegisterStorage)sp.Storage);
     arch.Stub(s => s.PointerType).Return(PrimitiveType.Pointer32);
     scanner.Stub(s => s.Services).Return(sc);
     sc.AddService<DecompilerEventListener>(listener);
 }
コード例 #10
0
 public void Setup()
 {
     MockRepository mock = new MockRepository();
     IDataModel stubDb = mock.Stub<IDataModel>();
     IDataQueryRepository stubReposit = mock.Stub<IDataQueryRepository>();
     MyInfoController = new myInfoController(stubDb, stubReposit);
 }
コード例 #11
0
ファイル: BusinessUnitTest.cs プロジェクト: gipasoft/Sfera
        protected void SetUp()
        {
            var mocks = new MockRepository();

            var azienda = new Azienda("PROV", "Azienda di prova");
            var condominio = new Condominio("Condominio di prova", 31, 12, 2012, azienda);

            var stabile = new Palazzina(condominio, "Stabile di prova", false);
            condominio.Palazzine.Add(stabile);

            var scala = new GruppoStabile(stabile, "Scala di prova");
            var tipoUnitaImmobiliare = new TipoUnitaImmobiliare("Abitazione");
            var unitaImmobiliare = new UnitaImmobiliare(scala, tipoUnitaImmobiliare);
            var annoGestionale = new AnnoGestionale(condominio, 2012, 2012);
            _esercizio = new Esercizio(condominio, new DateTime(2012, 1, 1), new DateTime(2012, 12, 31), annoGestionale, GestioneEsercizioEnum.Ordinario);

            _subentroRepository = mocks.Stub<ISubentroUnitaImmobiliareDao>();

            var subentro1 = mocks.Stub<SubentroUnitaImmobiliare>();
            subentro1.SoggettoEntrante = new SoggettoCondominio(unitaImmobiliare, new Persona(TipoPersonaEnum.Fisica, "Giorgio", "Parmeggiani", 1, true));
            subentro1.SoggettoUscente = new SoggettoCondominio(unitaImmobiliare, new Persona(TipoPersonaEnum.Fisica, "Daniele", "Vaccari", 1, true));

            var subentro2 = mocks.Stub<SubentroUnitaImmobiliare>();
            subentro1.SoggettoEntrante = new SoggettoCondominio(unitaImmobiliare, subentro1.SoggettoUscente.Persona);
            subentro1.SoggettoUscente = new SoggettoCondominio(unitaImmobiliare, new Persona(TipoPersonaEnum.Fisica, "Luigi", "Cacciatori", 1, true));

            using (mocks.Record())
            {
                SetupResult.For(_subentroRepository.GetByDataCondominio(_esercizio.CondominioRiferimento.ID, _esercizio.DataApertura.GetValueOrDefault(), _esercizio.DataChiusura.GetValueOrDefault(), false)).Return(new List<SubentroUnitaImmobiliare> { subentro1, subentro2 });
            }

        }
コード例 #12
0
ファイル: HookStub.cs プロジェクト: Wosad/Wosad.Design
        private StandardHookInTension CreateHookObject(double ConcStrength, double RebarDiameter, bool IsEpoxyCoated,
    ConcreteTypeByWeight typeByWeight, double ExcessFlexureReinforcementRatio)
        {
            MockRepository mocks = new MockRepository();

            IRebarMaterial rebarMat = mocks.Stub<IRebarMaterial>();
            Expect.Call(rebarMat.YieldStress).Return(60000);
            Rebar rebar = new Rebar(RebarDiameter,IsEpoxyCoated, rebarMat);

            ICalcLogEntry entryStub = mocks.Stub<ICalcLogEntry>();
            ICalcLog logStub = mocks.Stub<ICalcLog>();

            //IConcreteMaterial ConcStub = mocks.Stub<IConcreteMaterial>();
            IConcreteMaterial ConcStub = new ConcreteMaterial(ConcStrength, typeByWeight, logStub) as IConcreteMaterial;
            ConcStub.SpecifiedCompressiveStrength = ConcStrength;
            ConcStub.TypeByWeight = typeByWeight;


            using (mocks.Record())
            {
                logStub.CreateNewEntry();
                LastCall.Return(entryStub);
            }

            StandardHookInTension tensHook = new StandardHookInTension(ConcStub, rebar, logStub, ExcessFlexureReinforcementRatio);

            return tensHook;
        }
コード例 #13
0
ファイル: HBaseRowTests.cs プロジェクト: nordbergm/HBaseNet
        public void LoadsOnLoad()
        {
            MockRepository mockRepository = new MockRepository();
            IHBaseConnection connection = mockRepository.Stub<IHBaseConnection>();
            IHBaseRowData rowData = mockRepository.Stub<IHBaseRowData>();
            IHBaseCellData cellData = mockRepository.Stub<IHBaseCellData>();

            byte[] tableName = Encoding.UTF8.GetBytes("t");
            byte[] rowKey = Encoding.UTF8.GetBytes("r");
            byte[] columnName = Encoding.UTF8.GetBytes("c");

            using (mockRepository.Record())
            {
                SetupResult.For(rowData.Key).Return(rowKey);
                SetupResult.For(rowData.Columns).Return(new Dictionary<byte[], IList<IHBaseCellData>> { { columnName, new List<IHBaseCellData> { cellData } } });
                SetupResult.For(connection.GetRow(tableName, rowKey)).Return(rowData);
            }

            using (mockRepository.Playback())
            {
                HBaseDatabase db = new HBaseDatabase(connection);
                HBaseRow row = new HBaseRow(Encoding.UTF8.GetBytes("r"), new HBaseTable(Encoding.UTF8.GetBytes("t"), db));
                row.Load();

                Assert.Equal(1, row.Columns.Keys.Count);
            }
        }
コード例 #14
0
        public void Setup()
        {
            mr = new MockRepository();
            mockFactory = new MockFactory(mr);
            var platform = mockFactory.CreatePlatform();
            var imageMap = new SegmentMap(Address32.Ptr32(0x05));
            program = new Program(imageMap, platform.Architecture, platform);
            interactor = new CombinedCodeViewInteractor();
            var uiPreferencesSvc = mr.Stub<IUiPreferencesService>();
            var uiSvc = mr.Stub<IDecompilerShellUiService>();

            var styles = new Dictionary<string, UiStyle>()
            {
                {
                    UiStyles.CodeWindow,
                    new UiStyle
                    {
                        Background = new SolidBrush(Color.White),
                    }
                }
            };
            uiPreferencesSvc.Stub(u => u.Styles).Return(styles);
            var sc = new ServiceContainer();
            sc.AddService<IUiPreferencesService>(uiPreferencesSvc);
            sc.AddService<IDecompilerShellUiService>(uiSvc);
            interactor.SetSite(sc);
        }
コード例 #15
0
 public void Setup()
 {
     this.mr = new MockRepository();
     this.sc = new ServiceContainer();
     loader = mr.Stub<ILoader>();
     arch = mr.StrictMock<IProcessorArchitecture>();
     Address dummy;
     arch.Stub(a => a.TryParseAddress(null, out dummy)).IgnoreArguments().WhenCalled(m =>
     {
         Address addr;
         var sAddr = (string)m.Arguments[0];
         var iColon = sAddr.IndexOf(':');
         if (iColon > 0)
         {
             addr = Address.SegPtr(
                 Convert.ToUInt16(sAddr.Remove(iColon)),
                 Convert.ToUInt16(sAddr.Substring(iColon+1)));
             m.ReturnValue = true;
         }
         else
         {
             m.ReturnValue = Address32.TryParse32((string)m.Arguments[0], out addr);
         }
         m.Arguments[1] = addr;
     }).Return(false);
     this.cfgSvc = mr.Stub<IConfigurationService>();
     this.sc.AddService<IConfigurationService>(cfgSvc);
 }
コード例 #16
0
ファイル: Rewrite32.cs プロジェクト: killbug2004/reko
 public void Setup()
 {
     mr = new MockRepository();
     var services = mr.Stub<IServiceProvider>();
     var tlSvc = mr.Stub<ITypeLibraryLoaderService>();
     var configSvc = mr.StrictMock<IConfigurationService>();
     var win32env = new OperatingEnvironmentElement
     {
         TypeLibraries = 
         {
             new TypeLibraryElement {  Name= "msvcrt.xml" },
             new TypeLibraryElement {  Name= "windows32.xml" },
         }
     };
     configSvc.Stub(c => c.GetEnvironment("win32")).Return(win32env);
     configSvc.Stub(c => c.GetPath(null)).IgnoreArguments()
         .Do(new Func<string, string>(s => s));
     services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tlSvc);
     services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(configSvc);
     tlSvc.Stub(t => t.LoadLibrary(null, null)).IgnoreArguments()
         .Do(new Func<IProcessorArchitecture, string, TypeLibrary>((a, n) =>
         {
             var lib = TypeLibrary.Load(a, Path.ChangeExtension(n, ".xml"));
             return lib;
         }));
     services.Replay();
     tlSvc.Replay();
     configSvc.Replay();
     arch = new IntelArchitecture(ProcessorMode.Protected32);
     win32 = new Decompiler.Environments.Win32.Win32Platform(services, arch);
 }
コード例 #17
0
        public void ArrayConstructIsParsed()
        {
            MockRepository mocks = new MockRepository();
              IBlacklistManager blacklistManager = mocks.Stub<IBlacklistManager>();
              Dictionary<string, bool> locallyInitializedArrays = new Dictionary<string, bool>();
              BlockParserContext blockParserContext = new BlockParserContext (
              new ProblemPipeStub(),
              Fragment.CreateNamed ("returnFragmentType"),
              new List<ReturnCondition>(),
              blacklistManager,
              delegate { });
              ArrayConstructStatementHandler handler = new ArrayConstructStatementHandler (blockParserContext);

              Method sampleMethod = IntrospectionUtility.MethodFactory<ArrayConstructStatementHandlerSample> ("LocallyInitializedArray");
              Block sampleBlock = (Block) sampleMethod.Body.Statements[0];
              Statement sample = sampleBlock.Statements[1];

              ISymbolTable symbolTable = mocks.Stub<ISymbolTable>();
              HandleContext context = new HandleContext (
              sample,
              symbolTable,
              new List<IPreCondition>(),
              new List<string>(),
              new List<BlockAssignment>(),
              new List<int>(),
              locallyInitializedArrays,
              new Dictionary<string, bool>());
              handler.Handle (context);

              bool locallyInitializedArrayAdded = locallyInitializedArrays.ContainsKey ("local$2") && locallyInitializedArrays["local$2"] == false;
              Assert.That (locallyInitializedArrayAdded, Is.True);
        }
コード例 #18
0
ファイル: SysVPlatformTests.cs プロジェクト: melbcat/reko
        public void SysV_TerminatingFunction()
        {
            var mr = new MockRepository();
            var sc = new ServiceContainer();
            var arch = mr.Stub<IProcessorArchitecture>();
            var tlSvc = mr.Stub<ITypeLibraryLoaderService>();
            var cfgSvc = mr.Stub<IConfigurationService>();
            sc.AddService<IConfigurationService>(cfgSvc);
            sc.AddService<ITypeLibraryLoaderService>(tlSvc);
            cfgSvc.Stub(c => c.GetEnvironment(null))
                .IgnoreArguments()
                .Return(new OperatingEnvironmentElement
                {
                     TypeLibraries = 
                     {
                         new TypeLibraryElement 
                         {
                              Name="libc.xml"
                         }
                     },
                     CharacteristicsLibraries =
                     {
                         new TypeLibraryElement
                         {
                             Name="libcharacteristics.xml",
                         }
                     }
                });
            tlSvc.Stub(t => t.LoadCharacteristics(null))
                .IgnoreArguments()
                .Return(new CharacteristicsLibrary
                {
                    Entries =
                    {
                        { 
                            "exit", 
                            new ProcedureCharacteristics {
                                Terminates = true
                            }
                        }
                    }
                });
            tlSvc.Stub(t => t.LoadLibrary(null, null))
                .IgnoreArguments()
                .Return(new TypeLibrary
                {
                    Signatures =
                    {
                         {
                            "exit",
                            new ProcedureSignature(null)
                         }
                     }
                });
            mr.ReplayAll();

            var sysv = new SysVPlatform(sc, arch);
            var proc = sysv.LookupProcedureByName(null, "exit");
            Assert.IsTrue(proc.Characteristics.Terminates, "exit should have been marked as terminating.");
        }
コード例 #19
0
ファイル: ValuePropagationTests.cs プロジェクト: uxmal/reko
		public void Setup()
		{
			ssaIds = new SsaIdentifierCollection();
            mr = new MockRepository();
            arch = mr.Stub<IProcessorArchitecture>();
            importResolver = mr.Stub<IImportResolver>();
		}
コード例 #20
0
        public void Build_ReturnsAllStatementHandlersNeededByBlockParser()
        {
            MockRepository mocks = new MockRepository();
              IBlacklistManager blacklistManager = mocks.Stub<IBlacklistManager>();
              IProblemPipe problemPipe = mocks.Stub<IProblemPipe>();
              BlockParserContext blockParserContext = new BlockParserContext (
              problemPipe,
              Fragment.CreateNamed ("returnFragmentType"),
              new List<ReturnCondition>(),
              blacklistManager,
              delegate { });
              StatementHandlerDictionaryBuilder builder = new StatementHandlerDictionaryBuilder (blockParserContext);

              Dictionary<Type, IStatementHandler> handlers = builder.Build();
              bool assignmentStatementSupported = handlers.ContainsKey (typeof (AssignmentStatement));
              bool branchSupported = handlers.ContainsKey (typeof (Branch));
              bool expressionStatementSupported = handlers.ContainsKey (typeof (ExpressionStatement));
              bool returnNodeSupported = handlers.ContainsKey (typeof (ReturnNode));
              bool switchInstructionSupported = handlers.ContainsKey (typeof (SwitchInstruction));

              bool necessaryHandlersSupported = assignmentStatementSupported
                                        && branchSupported
                                        && expressionStatementSupported
                                        && returnNodeSupported
                                        && switchInstructionSupported;

              bool correctHandlerCount = handlers.Keys.Count == 5;

              Assert.That (necessaryHandlersSupported && correctHandlerCount, Is.True);
        }
コード例 #21
0
        /// <summary>
        ///     The test window.
        /// </summary>
        public void TestWindow()
        {
            var mocks = new MockRepository();
            var mockHttpReq = mocks.Stub<IHttpSonarConnector>();
            var mockVsHelpers = mocks.Stub<IVsEnvironmentHelper>();
            var config = new ConnectionConfiguration("serveraddr", "login", "password");

            // set expectations
            using (mocks.Record())
            {
                SetupResult.For(mockHttpReq.HttpSonarGetRequest(config, "/api/issues/search?components=resource"))
                    .Return(File.ReadAllText("TestData/issuessearchbycomponent.txt"));
                SetupResult.For(mockHttpReq.HttpSonarGetRequest(config, "/api/users/search")).Return(File.ReadAllText("TestData/userList.txt"));
            }

            ISonarRestService service = new SonarRestService(mockHttpReq);
            var issues = service.GetIssuesInResource(config, "resource");
            var associatedProject = new Resource { Key = "core:Common" };

            this.model = new ExtensionDataModel(service, mockVsHelpers, associatedProject);
            var t = new Thread(this.Threadprc);
            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();
        }
コード例 #22
0
        public void CanReadFromValidStream()
        {
            string testString = "26/09/2008,1204.47,1215.77,1187.54,1213.27,5383610000,1213.27";
            MockRepository mocks = new MockRepository();
            TextReader sourceReader  = mocks.Stub<TextReader>();

                using (mocks.Record())
                {
                    SetupResult
                        .For(sourceReader.ReadLine())
                        .Return(testString);
                }

                IParseIntervals intervalParser = mocks.Stub<IParseIntervals>();

            using (mocks.Record())
                {
                    SetupResult
                        .For(intervalParser.Parse("qwert", 0))
                        .IgnoreArguments()
                        .Return(new OHLCVInterval()
                        {
                             Close = 1213.27f,
                             // DataSource="Stub",
                               DateTime=new DateTime(2008,09,26),
                                High=1215.77f,
                                 Index=0,
                                  Instrument="StubInstrument",
                                   //Interval="Day",
                                   Exchange="StubExchange",
                                     Low=1187.54f,
                                      Open=1204.47f,
                                       Volume=5383610000,
                                       //Id = Guid.NewGuid()//"StubInstrument" + new DateTime(2008,09,26).Ticks.ToString()
                        }
                        );
                }

            bool hasHeader = false;

              OHLCVIntervalReader reader = new OHLCVIntervalReader(sourceReader, intervalParser, hasHeader);

              foreach (var interval in reader)
              {
              Assert.AreEqual(new DateTime(2008, 09, 26), interval.DateTime);
              Assert.IsFalse(Math.Abs(1204.47f - interval.Open) > Single.Epsilon);
              Assert.IsFalse(Math.Abs(1215.77f - interval.High) > Single.Epsilon);
              Assert.IsFalse(Math.Abs(1187.54f - interval.Low) > Single.Epsilon);
              Assert.IsFalse(Math.Abs(1213.27f - interval.Close) > Single.Epsilon);
              Assert.AreEqual(5383610000, interval.Volume);
              Assert.AreEqual(0, interval.Index);
              Assert.AreEqual("StubExchange", interval.Exchange);

              //Assert.AreEqual("Stub", interval.DataSource);
              Assert.AreEqual("StubInstrument", interval.Instrument);
             // Assert.AreEqual("StubInstrument" + new DateTime(2008, 09, 26).Ticks.ToString(), interval.Id);
              break;
              }
        }
コード例 #23
0
 public void SetUp()
 {
     _mocks = new MockRepository();
     _repository = _mocks.Stub<IRepository>();
     _operationRepository = _mocks.Stub<IOperationRepository>();
     _accountRepository = _mocks.Stub<IAccountRepository>();
     _helper = _mocks.Stub<IHelper>();
 }
コード例 #24
0
ファイル: ProjectLoaderTests.cs プロジェクト: uxmal/reko
 public void Setup()
 {
     this.mr = new MockRepository();
     this.mockFactory = new MockFactory(mr);
     this.sc = new ServiceContainer();
     this.cfgSvc = mr.Stub<IConfigurationService>();
     this.listener = mr.Stub<DecompilerEventListener>();
     this.sc.AddService<IConfigurationService>(cfgSvc);
 }
コード例 #25
0
 public void Setup()
 {
     mr = new MockRepository();
     sc = new ServiceContainer();
     site = new FakeComponentSite(sc);
     site.AddService<IDecompilerService>(mr.Stub<IDecompilerService>());
     site.AddService<IDecompilerShellUiService>(mr.Stub<IDecompilerShellUiService>());
     site.AddService<IWorkerDialogService>(mr.Stub<IWorkerDialogService>());
 }
コード例 #26
0
 public void SetUp()
 {
     mocks = new MockRepository();
     session = mocks.DynamicMock<ISession>();
     sessionFactory = mocks.DynamicMock<ISessionFactory>();
     store = new ThreadedUnitOfWorkStore();
     factory = mocks.Stub<NHibernateUnitOfWorkFactory<NullDatabase>>(sessionFactory);
     unitOfWorkManager = mocks.Stub<NHibernateUnitOfWorkManager>();
     unitOfWorkManager.Add(new NullDatabase(factory, store));
 }
コード例 #27
0
ファイル: UnpackingServiceTests.cs プロジェクト: relaxar/reko
 public void Setup()
 {
     mr = new MockRepository();
     sc = new ServiceContainer();
     cfgSvc = mr.Stub<IConfigurationService>();
     fsSvc = mr.Stub<IFileSystemService>();
     diagSvc = mr.Stub<IDiagnosticsService>();
     sc.AddService<IFileSystemService>(fsSvc);
     sc.AddService<IDiagnosticsService>(diagSvc);
 }
コード例 #28
0
ファイル: SysVPlatformTests.cs プロジェクト: relaxar/reko
        public void Setup()
        {
            this.mr = new MockRepository();
            this.sc = new ServiceContainer();
            this.arch = mr.Stub<IProcessorArchitecture>();
            this.tlSvc = mr.Stub<ITypeLibraryLoaderService>();
            this.cfgSvc = mr.Stub<IConfigurationService>();
            sc.AddService<IConfigurationService>(cfgSvc);
            sc.AddService<ITypeLibraryLoaderService>(tlSvc);

        }
コード例 #29
0
        public void SetUp()
        {
            mocks= new MockRepository();

            mockSQLModel = mocks.DynamicMock<SQLDataServiceModel>();
            mockSQLModel.sqlService = mocks.Stub<ISQLWebService>(mocks.Stub<InstanceContext>());
            mockSQLModel.EncryptionSeed = "1234";
            stubQuery = mocks.Stub<SQLDataQueryRepository>();

            goodController = new GoodsInfoController(mockSQLModel,stubQuery);
        }
コード例 #30
0
        public void Setup()
        {
            repository = new MockRepository();
            interactor = repository.Stub<DisassemblyViewInteractor>();
            sc = new ServiceContainer();
            uiSvc = repository.DynamicMock<IDecompilerShellUiService>();
            dcSvc = repository.Stub<IDecompilerService>();
            dlgFactory = repository.DynamicMock<IDialogFactory>();
            sc.AddService<IDecompilerShellUiService>(uiSvc);

            sc.AddService<IDecompilerService>(dcSvc);
            sc.AddService<IDialogFactory>(dlgFactory);
        }