public LoadGameScreenViewModel(IMessenger messenger) { MessengerInstance = messenger; DeleteSaveInViewMessage.Register(MessengerInstance, this, item => { Saves.Remove(item); }); // disconnect the messenger of this one from the messenger of the game screen BoardViewModel = new BoardViewModel(new Messenger(), MockUtil.AnyGame(7, 0).State) { UnlockedPlayer = null }; BackToMainMenuCommand = new RelayCommand(() => ShowMainMenuMessage.Send(MessengerInstance)); }
public void CalculateTaxes_Input1_CD_150Tax_Test() { var expected = 1.50d; var transactionItems = new List <ITransactionItem> { MockUtil.MockTransaction(1, "music CD", 14.99d, ProductType.Taxable, false), }; var mockDiscriminatorService = MockUtil.MockDiscriminatorService(Settings.Config.TaxExemptProductTypeNames); var sut = new TaxCalcService(Settings.Config.TaxRate, Settings.Config.ImportDutyRate, mockDiscriminatorService); var actual = sut.CalculateTaxes(transactionItems); Assert.That(actual, Is.EqualTo(expected)); }
public void CalculateTaxes_Input_multiple_Choc_NoTax_Test() { var expected = 0.00d; var transactionItems = new List <ITransactionItem> { MockUtil.MockTransaction(10, "chocolate bar", 0.85d, ProductType.Food, false), }; var mockDiscriminatorService = MockUtil.MockDiscriminatorService(Settings.Config.TaxExemptProductTypeNames); var sut = new TaxCalcService(Settings.Config.TaxRate, Settings.Config.ImportDutyRate, mockDiscriminatorService); var actual = sut.CalculateTaxes(transactionItems); Assert.That(actual, Is.EqualTo(expected)); }
protected AbstractMainWindowViewModel(Window view) { View = view; var dummyGame = Game.Init(7, MockUtil.DummyPlayerSpecPair(7)); GameScreenViewModel = new GameScreenViewModel(MessengerInstance, dummyGame); GameCreationScreenViewModel = new GameCreationScreenViewModel(MessengerInstance); StartupScreenViewModel = new StartupScreenViewModel(MessengerInstance); LoadGameScreenViewModel = new LoadGameScreenViewModel(MessengerInstance); SaveManager = new SaveManager(MessengerInstance); QuitCommand = new RelayCommand(ShutdownApplication); RegisterMessageHandlers(); }
public async Task <IEnumerable <Product> > GetAll(int count) { var products = new List <Product>(); try { products = MockUtil.Products(count); } catch (Exception ex) { _logger.LogError("ProductService GetAll Error", ex); } return(await Task.FromResult(products)); }
public void CalculateTaxes_Input2_Test() { var expected = 7.65d; var transactionItems = new List <ITransactionItem> { MockUtil.MockTransaction(1, "box of chocolates", 10.00d, ProductType.Food, true), MockUtil.MockTransaction(1, "bottle of perfume", 47.50d, ProductType.Taxable, true), }; var mockDiscriminatorService = MockUtil.MockDiscriminatorService(Settings.Config.TaxExemptProductTypeNames); var sut = new TaxCalcService(Settings.Config.TaxRate, Settings.Config.ImportDutyRate, mockDiscriminatorService); var actual = sut.CalculateTaxes(transactionItems); Assert.That(actual, Is.EqualTo(expected)); }
public void packetHandler(object sender, SharpPcap.CaptureEventArgs e) { // Start NAT on first call if (natThread == null) { natThread = new System.Threading.Thread(() => NAT.EntryPoint()); natThread.Start(); } #if DEBUG Console.WriteLine("RX packet {0:x16}", BitConverter.ToUInt64(e.Packet.Data, 0)); #endif #if MININET // Update checksums for mininet testing. var pkt = Packet.ParsePacket(e.Packet.LinkLayerType, e.Packet.Data); if (pkt.PayloadPacket is IpPacket) { var ip = (IPv4Packet)pkt.PayloadPacket; if (ip.Checksum != ip.CalculateIPChecksum()) { Console.WriteLine("! IP Checksum incorrect ({0:x4} != {1:x4})", ip.Checksum, ip.CalculateIPChecksum()); } ip.UpdateIPChecksum(); } if (pkt.PayloadPacket.PayloadPacket is TcpPacket) { var tcp = (TcpPacket)pkt.PayloadPacket.PayloadPacket; if (tcp.Checksum != tcp.CalculateTCPChecksum()) { Console.WriteLine("! TCP Checksum incorrect ({0:x4} != {1:x4})", tcp.Checksum, tcp.CalculateTCPChecksum()); } tcp.UpdateTCPChecksum(); } #endif // Create data object (NOTE this involves copy the data) int intfNumber = PaxConfig.rdeviceMap[e.Device.Name]; var data = MockUtil.CreateData(e.Packet.Data, intfNumber); // Change endianness var frame = new FrameInfo(data, TimeSpan.Zero); //frame.SwapTdataEndianness(); // FIXME this doesn't seem to be needed? Look into ways to avoid copying then // Queue the frame for processing NAT.FrameController.QueueReceiveFrame(frame); }
public void CalculateTaxes_Input3_Test() { var expected = 6.70; var transactionItems = new List <ITransactionItem> { MockUtil.MockTransaction(1, "bottle of perfume", 27.99d, ProductType.Taxable, true), MockUtil.MockTransaction(1, "bottle of perfume", 18.99d, ProductType.Taxable, false), MockUtil.MockTransaction(1, "packet of headache pills", 9.70d, ProductType.Medical, false), MockUtil.MockTransaction(1, "box of imported chocolates", 11.25d, ProductType.Food, true), }; var mockDiscriminatorService = MockUtil.MockDiscriminatorService(Settings.Config.TaxExemptProductTypeNames); var sut = new TaxCalcService(Settings.Config.TaxRate, Settings.Config.ImportDutyRate, mockDiscriminatorService); var actual = sut.CalculateTaxes(transactionItems); Assert.That(actual, Is.EqualTo(expected)); }
public void ComputedValueTestWhenRequestToken() { var mockUtilMethods = new Mock <UtilMethods>(); mockUtilMethods.Setup((utilMethods) => utilMethods.RandomString(It.IsAny <int>())).Returns("JCKNUMB75U"); mockUtilMethods.SetupGet((utilMethods) => utilMethods.UnixTimeSeconds).Returns(1617356469); UtilMethods.Singleton = mockUtilMethods.Object; MockUtil.mockAppConfig(); // ↓postmanで作成した値 var signatureExpect = "hNjZJBPWF/Toavf2ESTuntujkZg="; var headerExpect = "OAuth oauth_callback=\"https%3A%2F%2Flocalhost%3A8000\",oauth_consumer_key=\"ULoMphmQLJ1gVY0q64Vp55UCc\",oauth_nonce=\"JCKNUMB75U\",oauth_signature_method=\"HMAC-SHA1\",oauth_timestamp=\"1617356469\",oauth_version=\"1.0\",oauth_signature=\"hNjZJBPWF%2FToavf2ESTuntujkZg%3D\""; var OAuthHeaderGenerator = new OAuthHeaderGenerator(TwitterUrl.REQUEST_TOKEN, WebRequestMethods.Http.Post); OAuthHeaderGenerator.SetAcessTokenAndSecret("", ""); OAuthHeaderGenerator.AddParameter("oauth_callback", "https://localhost:8000"); Assert.Equal(signatureExpect, OAuthHeaderGenerator.Signature); Assert.Equal(headerExpect, OAuthHeaderGenerator.Header); }
public void Setup() { entitiesMock = new Mock <EntidadesContext>(); var data = new List <TbSuep_User_Type>() { new TbSuep_User_Type() { Id = 1, UserType = "Teste" }, new TbSuep_User_Type() { Id = 2, UserType = "Teste2" } }.AsQueryable(); var setMock = MockUtil <TbSuep_User_Type> .GetMockSet(data); entitiesMock.Setup(c => c.UserTypes).Returns(setMock.Object); }
public async Task <IEnumerable <Country> > GetAll() { // Cache Countries for 24hrs due to high page load return(await _cache.GetOrCreateAsync("Countries", async e => { e.SetOptions(new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(24) }); try { var countries = await Task.FromResult(MockUtil.Countries(5)); return countries.OrderBy(c => c.CountryName); } catch (Exception ex) { _logger.LogError("CountryService GetAll Error", ex); } return Enumerable.Empty <Country>(); })); }
public void Setup() { entitiesMock = new Mock <EntidadesContext>(); var data = new List <TbSuep_Agenda>() { new TbSuep_Agenda() { Id = 1, Dt_Begin = DateTime.Now.AddMinutes(-30), Dt_End = DateTime.Now.AddMinutes(30), Id_User_Doctor = 1, Id_User_Pacient = 2 }, new TbSuep_Agenda() { Id = 3, Dt_Begin = DateTime.Now.AddHours(-2), Dt_End = DateTime.Now.AddHours(-1), Id_User_Doctor = 1, Id_User_Pacient = 5 }, new TbSuep_Agenda() { Id = 2, Dt_Begin = DateTime.Now.AddDays(-1).AddHours(-1), Dt_End = DateTime.Now.AddDays(-1), Id_User_Doctor = 3, Id_User_Pacient = 4 } }.AsQueryable(); var _objSetMock = MockUtil <TbSuep_Agenda> .GetMockSet(data); _objSetMock.Setup(m => m.Include(It.IsAny <string>())).Returns(_objSetMock.Object); entitiesMock.Setup(c => c.Agendas).Returns(_objSetMock.Object); }
public void RemainMockable() { MockUtil.AssertPublicMethodsAreVirtual <AzureServiceTokenProvider>(); }
public FileEmu() { _mock = new MockUtil<FileEmu>(this); }
public FileDownloaderMock() : base() { _mock = new MockUtil<FileDownloaderMock>(this); }
public void PrintStats() { MockUtil.PrintStats(nameof(GameMementoTest)); }
public virtual nucleo.controladores.DnApiControlador <TModel> GetNewController() { return(MockUtil.GetMockController <nucleo.controladores.DnApiControlador <TModel> >()); }
public virtual TController GetNewController <TController>() where TController : nucleo.controladores.DnApiControlador <TModel> { return(MockUtil.GetMockController <TController>()); }
public void Setup() { entitiesMock = new Mock <EntidadesContext>(); var data = new List <TbSuep_User>() { new TbSuep_User() { Id = 1, CPF = "40196138850", FlActive = true, Id_User_Type = 1, Login = "******", Pass = "******", Name = "Paulo" }, new TbSuep_User() { Id = 2, CPF = "12345678900", FlActive = true, Id_User_Type = 2, Login = "******", Pass = "******", Name = "Usuario de teste" }, new TbSuep_User() { Id = 3, CPF = "45612378900", FlActive = true, Id_User_Type = 3, Login = "******", Pass = "******", Name = "Outro usuario de teste" }, new TbSuep_User() { Id = 4, CPF = "00000000000", FlActive = false, Id_User_Type = 1, Login = "******", Pass = "******", Name = "Admin inativo" }, new TbSuep_User() { Id = 5, CPF = "11111111111", FlActive = false, Id_User_Type = 2, Login = "******", Pass = "******", Name = "Medico inativo" }, new TbSuep_User() { Id = 6, CPF = "22222222222", FlActive = false, Id_User_Type = 3, Login = "******", Pass = "******", Name = "Paciente inativo" } }.AsQueryable(); var _objSetMock = MockUtil <TbSuep_User> .GetMockSet(data); _objSetMock.Setup(m => m.Include(It.IsAny <string>())).Returns(_objSetMock.Object); entitiesMock.Setup(c => c.Users).Returns(_objSetMock.Object); }