private void ApplicantEducation_D_Test()
        {
            var client = new ApplicantEducation.ApplicantEducationClient(_channel);

            ApplicantEducationProto proto = client.GetApplicantEducation(new ApplicantEducationKey()
            {
                Id = _applicantEducation.Id.ToString()
            });
            ApplicantEducationList protos = new ApplicantEducationList();

            protos.Items.Add(proto);
            client.DeleteApplicantEducation(protos);
            proto = null;
            try
            {
                proto = client.GetApplicantEducation(new ApplicantEducationKey()
                {
                    Id = _applicantEducation.Id.ToString()
                });
            }
            catch (RpcException)
            {
            }
            Assert.IsNull(proto);
        }
        private ApplicantEducationProto CheckGetApplicantEducation(ApplicantEducation.ApplicantEducationClient client
                                                                   , ApplicantEducationKey key, ApplicantEducationProto compare = null)
        {
            ApplicantEducationProto proto = null;

            try
            {
                proto = client.GetApplicantEducation(key);
            }
            catch (RpcException)
            {
                Assert.Fail();
            }
            Assert.IsNotNull(proto);
            Assert.AreEqual(proto.Id, key.Id);
            if (compare != null)
            {
                Assert.AreEqual(proto.Applicant, compare.Applicant);
                Assert.AreEqual(proto.Major, compare.Major);
                Assert.AreEqual(proto.CertificateDiploma, compare.CertificateDiploma);
                Assert.AreEqual(proto.StartDate.ToDateTime().Date, compare.StartDate.ToDateTime().Date);
                Assert.AreEqual(proto.CompletionDate.ToDateTime().Date, compare.CompletionDate.ToDateTime().Date);
                Assert.AreEqual(proto.CompletionPercent, compare.CompletionPercent);
            }
            return(proto);
        }
Пример #3
0
        static async Task Main(string[] args)
        {
            var loggerFactory = LoggerFactory.Create(logging =>
            {
                logging.AddConsole();
                logging.SetMinimumLevel(LogLevel.Debug);
            });

            using var channel = GrpcChannel.ForAddress("https://localhost:5001",
                                                       new GrpcChannelOptions { LoggerFactory = loggerFactory });

            //var client = new Student.StudentClient(channel);
            //StudentReply reply = await client.GetStudentAsync(new StudentIDRequest { StudentID = 1 });
            //Console.WriteLine(reply.StudentID);

            var client = new ApplicantEducation.ApplicantEducationClient(channel);
            ApplicantEducationReply reply = await client.GetApplicantEducationAsync(new ApplicantEducationIdRequest { Id = "40FAA097-3A8C-E7A0-896C-1255EAC6A6D2" });

            ApplicantEducations replies = new ApplicantEducations();

            replies.AppEdus.Add(reply);
            await client.DeleteApplicantEducationAsync(replies);

            //var reply = await client.GetApplicantEducationsAsync(new Empty());
            //Console.WriteLine(reply.CurrentRate.ToDecimal());
        }
        private void ApplicantEducation_CRU_Test()
        {
            var client = new ApplicantEducation.ApplicantEducationClient(_channel);
            // add
            ApplicantEducationProto proto  = ProtoMapper.MapFromApplicantEducationPoco(_applicantEducation);
            ApplicantEducationList  protos = new ApplicantEducationList();

            protos.Items.Add(proto);
            client.AddApplicantEducation(protos);

            proto = CheckGetApplicantEducation(client, new ApplicantEducationKey()
            {
                Id = proto.Id
            }, proto);

            // check List
            protos = client.GetApplicantEducations(new Empty());
            Assert.IsTrue(protos.Items.Count > 0);

            // check update
            proto.Major = Faker.Education.Major();
            proto.CertificateDiploma = Faker.Education.Major();
            proto.StartDate          = ConvertDateTime2TimeStamp(Faker.Date.Past(3));
            proto.CompletionDate     = ConvertDateTime2TimeStamp(Faker.Date.Forward(1));

            proto.CompletionPercent = (byte)Faker.Number.RandomNumber(1);

            protos = new ApplicantEducationList();
            protos.Items.Add(proto);
            client.UpdateApplicantEducation(protos); // e9261fa9-f0c3-4603-b400-63a5f26952c7

            CheckGetApplicantEducation(client, new ApplicantEducationKey()
            {
                Id = proto.Id
            }, proto);
        }