public void ReportPlayer_ReturnErrorSaving_ReportResult() { try { var baseAddress = new Uri("net.tcp://localhost:8090/Contratos"); serviceHost = new ServiceHost(typeof(Contratos.MainService), baseAddress); System.ServiceModel.Channels.Binding binding = new NetTcpBinding(); var address = new EndpointAddress("net.tcp://localhost:8090/ServerTests"); var endpoint = serviceHost .AddServiceEndpoint(typeof(Contratos.IGameManager), binding, address.Uri); var smb = new ServiceMetadataBehavior { HttpGetEnabled = false }; serviceHost.Description.Behaviors.Add(smb); InstanceContext instanceContext = new InstanceContext(new GameManagerCallbackHandler()); gameClient = new GameManagerClient(instanceContext); endpoint.Name = gameClient.Endpoint.Name; InstanceContext instanceContext2 = new InstanceContext(new GameManagerCallbackHandler()); GameManagerClient gameClient2 = new GameManagerClient(instanceContext2); endpoint.Name = gameClient.Endpoint.Name; serviceHost.Open(); Jugador testPlayer = new Jugador { Apodo = "pklove3456", Contrasenia = "bobcholo1", }; gameClient.CreateMatch(testPlayer, CheckersGameMode.ClassicCheckers); Jugador testPlayer2 = new Jugador { Apodo = "frews2", Contrasenia = "frews1", }; gameClient2.CreateMatch(testPlayer2, CheckersGameMode.ClassicCheckers); serviceHost.Close(); gameClient.ReportPlayer(2, 1, "testReport reasonings"); GameManagerCallbackHandler gameHandler = new GameManagerCallbackHandler(); ReportSaveResult result = gameHandler.reportSaveResult; Assert.AreEqual(result, ReportSaveResult.ERROR_SAVING); } catch (EndpointNotFoundException) { gameClient.Abort(); } catch (CommunicationException) { gameClient.Abort(); } }
public void FinishPlayerGame_PlayerOneLose_int() { try { var baseAddress = new Uri("net.tcp://localhost:8090/Contratos"); serviceHost = new ServiceHost(typeof(Contratos.MainService), baseAddress); System.ServiceModel.Channels.Binding binding = new NetTcpBinding(); var address = new EndpointAddress("net.tcp://localhost:8090/ServerTests"); var endpoint = serviceHost .AddServiceEndpoint(typeof(Contratos.IGameManager), binding, address.Uri); var smb = new ServiceMetadataBehavior { HttpGetEnabled = false }; serviceHost.Description.Behaviors.Add(smb); InstanceContext instanceContext = new InstanceContext(new GameManagerCallbackHandler()); gameClient = new GameManagerClient(instanceContext); endpoint.Name = gameClient.Endpoint.Name; serviceHost.Open(); gameClient.FinishPlayerGame(1, 2, 10, 0); GameManagerCallbackHandler gameHandler = new GameManagerCallbackHandler(); int result = gameHandler.playerOneCheckers; Assert.AreEqual(result, 0); } catch (EndpointNotFoundException) { gameClient.Abort(); } catch (CommunicationException) { gameClient.Abort(); } }