public void ProjectAllItemsOfListOfM0M1ListOfM0FuncOfM0M1 <TItem, TOutput>(FakesDelegates.Func <List <TItem>, Func <TItem, TOutput>, List <TOutput> > func) where TOutput : class { Dictionary <Type, object> dict = null; if (!StubProjectAllItemsOfListOfM0M1ListOfM0FuncOfM0M1.TryGetValue(typeof(TItem), out dict)) { dict = new Dictionary <Type, object>(); StubProjectAllItemsOfListOfM0M1ListOfM0FuncOfM0M1.Add(typeof(TItem), dict); } dict.Add(typeof(TOutput), func); }
public void GetRandomAsOfM0M1ListOfM0 <TItem, TOutput>(FakesDelegates.Func <List <TItem>, TOutput> func) where TOutput : class { Dictionary <Type, object> dict = null; if (!StubGetRandomAsOfM0M1ListOfM0.TryGetValue(typeof(TItem), out dict)) { dict = new Dictionary <Type, object>(); StubGetRandomAsOfM0M1ListOfM0.Add(typeof(TItem), dict); } dict.Add(typeof(TOutput), func); }
/// <summary> /// Initializes the main view model with a set up dialog open and words service stubs. /// </summary> /// <param name="openAddDialog">The action to open add dialog.</param> /// <param name="allWordsGet">The action to get all words.</param> /// <param name="addWord">The action to add a word.</param> /// <param name="removeWord">The action to remove a word.</param> /// <param name="updateWord">The action to update a word.</param> /// <param name="getWords">The action to get words.</param> /// <returns> /// The initialized instance of <see cref="MainViewModel"/>. /// </returns> /// <owner>Mariia Yelisieieva</owner> private MainViewModel GetMainViewModel( FakesDelegates.Action openAddDialog = null, FakesDelegates.Func <List <Word> > allWordsGet = null, FakesDelegates.Action <Word> addWord = null, FakesDelegates.Action <Word> removeWord = null, FakesDelegates.Action <Word> updateWord = null, FakesDelegates.Func <Task> getWords = null) { var dialogOpen = new StubIDialogOpen() { OpenAddWindowDialog = openAddDialog }; var wordsService = new StubIWordsService() { AllWordsGet = allWordsGet, AddWord = addWord, GetWordsAsync = getWords, RemoveWord = removeWord, UpdateWord = updateWord }; MainViewModel viewModel = new MainViewModel(wordsService, dialogOpen); return(viewModel); }
private CpuState Test(CpuState cpuState) { var mem = new Dictionary<ushort, byte>(); foreach (var m in cpuState.Memory) { mem.Add(m.Address, m.Value); } var read = new FakesDelegates.Func<ushort, byte>(a => { if (!mem.ContainsKey(a)) { return 0; // Only writes allocate memory } return mem[a]; }); var readW = new FakesDelegates.Func<ushort, ushort>(a => { var hi = read(a); var lo = read((ushort)(a + 1)); return (ushort)((hi << 8) | lo); }); var mmu = new StubIMmu(); mmu.ReadByteUInt16 = read; mmu.ReadWordUInt16 = readW; mmu.WriteByteUInt16Byte = (a, v) => { mem[a] = v; }; mmu.WriteWordUInt16UInt16 = (a, v) => { mem[a] = (byte)((v & 0xFF00) >> 8); mem[(ushort)(a + 1)] = (byte)(v & 0xFF); }; var cpu = new TestCpu(mmu, cpuState.A, cpuState.B, cpuState.C, cpuState.D, cpuState.E, cpuState.H, cpuState.L, cpuState.SP, cpuState.PC, cpuState.FZ, cpuState.FN, cpuState.FH, cpuState.FC, cpuState.IME); cpu.Step(); return new CpuState { A = cpu.A, B = cpu.B, C = cpu.C, D = cpu.D, E = cpu.E, H = cpu.H, L = cpu.L, SP = cpu.SP, PC = cpu.PC, FZ = cpu.FZ, FN = cpu.FN, FH = cpu.FH, FC = cpu.FC, IME = cpu.IME, Memory = mem.Keys.OrderBy(k => k).Select(k => { var v = mem[k]; return new MemoryRecord { Address = k, Value = v }; }).ToList() }; }
public void GetRandomOf2ListOfM0 <TItem>(FakesDelegates.Func <List <TItem>, TItem> func) { StubGetRandomOf2ListOfM0.Add(typeof(TItem), func); }
private CpuState Test(CpuState cpuState) { var mem = new Dictionary <ushort, byte>(); foreach (var m in cpuState.Memory) { mem.Add(m.Address, m.Value); } var read = new FakesDelegates.Func <ushort, byte>(a => { if (!mem.ContainsKey(a)) { return(0); // Only writes allocate memory } return(mem[a]); }); var readW = new FakesDelegates.Func <ushort, ushort>(a => { var hi = read(a); var lo = read((ushort)(a + 1)); return((ushort)((hi << 8) | lo)); }); var mmu = new StubIMmu(); mmu.ReadByteUInt16 = read; mmu.ReadWordUInt16 = readW; mmu.WriteByteUInt16Byte = (a, v) => { mem[a] = v; }; mmu.WriteWordUInt16UInt16 = (a, v) => { mem[a] = (byte)((v & 0xFF00) >> 8); mem[(ushort)(a + 1)] = (byte)(v & 0xFF); }; var cpu = new TestCpu(mmu, cpuState.A, cpuState.B, cpuState.C, cpuState.D, cpuState.E, cpuState.H, cpuState.L, cpuState.SP, cpuState.PC, cpuState.FZ, cpuState.FN, cpuState.FH, cpuState.FC, cpuState.IME); cpu.Step(); return(new CpuState { A = cpu.A, B = cpu.B, C = cpu.C, D = cpu.D, E = cpu.E, H = cpu.H, L = cpu.L, SP = cpu.SP, PC = cpu.PC, FZ = cpu.FZ, FN = cpu.FN, FH = cpu.FH, FC = cpu.FC, IME = cpu.IME, Memory = mem.Keys.OrderBy(k => k).Select(k => { var v = mem[k]; return new MemoryRecord { Address = k, Value = v }; }).ToList() }); }