Beispiel #1
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <delete_employee employeeid=""E1234"" />
</function>";

            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings();

            xmlSettings.Encoding    = Encoding.UTF8;
            xmlSettings.Indent      = true;
            xmlSettings.IndentChars = "    ";

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            EmployeeDelete record = new EmployeeDelete("unittest");

            record.EmployeeId = "E1234";

            record.WriteXml(ref xml);

            xml.Flush();
            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd())
                           .WithDifferenceEvaluator(DifferenceEvaluators.Default)
                           .Build();

            Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString());
        }
Beispiel #2
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <delete_employee employeeid=""E1234"" />
</function>";

            EmployeeDelete record = new EmployeeDelete("unittest")
            {
                EmployeeId = "E1234"
            };

            this.CompareXml(expected, record);
        }
        public async Task <int> Delete(EmployeeDelete input)
        {
            try
            {
                var entity =
                    await _ERepository.GetAll().SingleOrDefaultAsync(p =>
                                                                     p.Id == input.Id && p.IsDeleted == false);

                if (entity.FUserId != 0)
                {
                    await _UserRepository.DeleteAsync(entity.FUserId);
                }

                entity.IsDeleted = true;
                await _ERepository.UpdateAsync(entity);

                return(1);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(0);
            }
        }