Successful unit test setup and tear down
This commit is contained in:
		
							
								
								
									
										60
									
								
								Aurora.test/ControllerTests/MembersControllerTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								Aurora.test/ControllerTests/MembersControllerTest.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
			
		||||
using NUnit.Framework;
 | 
			
		||||
using Aurora.Proto.PartyV2;
 | 
			
		||||
using Aurora.Services.Server;
 | 
			
		||||
using Grpc.Core;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace Aurora.test.ControllerTests
 | 
			
		||||
{
 | 
			
		||||
    public class MemberControllerTests
 | 
			
		||||
    {
 | 
			
		||||
        private RemotePartyService.RemotePartyServiceClient _remotePartyService;
 | 
			
		||||
        private Channel _channel;
 | 
			
		||||
        [SetUp]
 | 
			
		||||
        public void Setup()
 | 
			
		||||
        {
 | 
			
		||||
            ServerService.Instance.Start("testParty", "asdf");
 | 
			
		||||
            _channel = new Channel(string.Format("{0}:{1}", ServerService.GetLocalIPAddress(), 8080), ChannelCredentials.Insecure);
 | 
			
		||||
            _remotePartyService = new RemotePartyService.RemotePartyServiceClient(_channel);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [TearDown]
 | 
			
		||||
        public async Task TearDown()
 | 
			
		||||
        {
 | 
			
		||||
            await ServerService.Instance.Stop();
 | 
			
		||||
            await _channel.ShutdownAsync();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Test]
 | 
			
		||||
        public void DefaultTest()
 | 
			
		||||
        {
 | 
			
		||||
            ListMembersResponse resp = _remotePartyService.ListMembers(new ListMembersRequest()
 | 
			
		||||
            {
 | 
			
		||||
                Parent = "party1",
 | 
			
		||||
                PageSize = 10,
 | 
			
		||||
            });
 | 
			
		||||
            Assert.NotNull(resp);
 | 
			
		||||
            Assert.GreaterOrEqual(resp.Members.Count, 1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Test]
 | 
			
		||||
        [TestCase("Alex")]
 | 
			
		||||
        [TestCase("Alex Goldberg")]
 | 
			
		||||
        [TestCase("Alex/goldberg")]
 | 
			
		||||
        [TestCase("alex@welcome.com")]
 | 
			
		||||
        public void CreateMemberTest(string value)
 | 
			
		||||
        {
 | 
			
		||||
            Member member = _remotePartyService.CreateMember(new CreateMemberRequest()
 | 
			
		||||
            {
 | 
			
		||||
                Parent = "party1",
 | 
			
		||||
                Member = new Member()
 | 
			
		||||
                {
 | 
			
		||||
                    UserName = value,
 | 
			
		||||
                    IpAddress = ServerService.GetLocalIPAddress(),
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            Assert.NotNull(member);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										37
									
								
								Aurora.test/ControllerTests/PartyControllerTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Aurora.test/ControllerTests/PartyControllerTest.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using NUnit.Framework;
 | 
			
		||||
using Aurora.Proto.PartyV2;
 | 
			
		||||
using Aurora.Services.Server;
 | 
			
		||||
using Grpc.Core;
 | 
			
		||||
 | 
			
		||||
namespace Aurora.test.ControllerTests
 | 
			
		||||
{
 | 
			
		||||
    public class PartyControllerTests
 | 
			
		||||
    {
 | 
			
		||||
        private RemotePartyService.RemotePartyServiceClient _remotePartyService;
 | 
			
		||||
        private Channel _channel;
 | 
			
		||||
        [SetUp]
 | 
			
		||||
        public void Setup()
 | 
			
		||||
        {
 | 
			
		||||
            ServerService.Instance.Start("testParty", "asdf");
 | 
			
		||||
            _channel = new Channel(string.Format("{0}:{1}", ServerService.GetLocalIPAddress(), 8080), ChannelCredentials.Insecure);
 | 
			
		||||
            _remotePartyService = new RemotePartyService.RemotePartyServiceClient(_channel);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [TearDown]
 | 
			
		||||
        public async Task TearDown()
 | 
			
		||||
        {
 | 
			
		||||
            await ServerService.Instance.Stop();
 | 
			
		||||
            await _channel.ShutdownAsync();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Test]
 | 
			
		||||
        public void DefaultTest()
 | 
			
		||||
        {
 | 
			
		||||
            Party party = _remotePartyService.GetParty(new Proto.General.Empty());
 | 
			
		||||
 | 
			
		||||
            Assert.NotNull(party);
 | 
			
		||||
            Assert.AreEqual(party.Name, "party/party1");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user