Ejemplo n.º 1
0
        public void ShareTests(float àrg1, float arg2, float exp)
        {
            Mathematician mathematician = new Mathematician();
            decimal       result        = mathematician.Share((decimal)àrg1, (decimal)arg2);

            Assert.AreEqual(exp, (float)result, 0.00001);
        }
Ejemplo n.º 2
0
        [TestCase(-465, -2, -463)]            //!
        public void SubtractTests(decimal àrg1, decimal arg2, decimal exp)
        {
            Mathematician mathematician = new Mathematician();
            decimal       result        = mathematician.Subtract(àrg1, arg2);

            Assert.AreEqual(exp, result);
        }
Ejemplo n.º 3
0
        public void MultiplyTests(decimal àrg1, decimal arg2, decimal exp)
        {
            Mathematician mathematician = new Mathematician();
            decimal       result        = mathematician.Multiply(àrg1, arg2);

            Assert.AreEqual((float)exp, (float)result, 0.000001);
        }
Ejemplo n.º 4
0
        public void CutDisplayTests(string àrg1, string exp)
        {
            Mathematician mathematician = new Mathematician();
            string        result        = mathematician.CutDisplay(àrg1);

            Assert.AreEqual(exp, result);
        }
Ejemplo n.º 5
0
        public void ToFoldTests(decimal àrg1, decimal arg2, decimal exp)
        {
            Mathematician mathematician = new Mathematician();
            decimal       result        = mathematician.ToFold(àrg1, arg2);

            Assert.AreEqual(exp, result);
        }
Ejemplo n.º 6
0
        public IHttpActionResult CreateMathematician(MathematicianRepresentation representation)
        {
            Guid uniqueGuid = Guid.Empty;

            if (!Guid.TryParse(representation.unique, out uniqueGuid))
            {
                return(BadRequest());
            }

            using (var context = GetContext())
            {
                var mathematician = LoadMathematician(context, uniqueGuid);

                if (mathematician == null)
                {
                    mathematician = context.Mathematicians.Add(Mathematician.Create(uniqueGuid));
                    SetName(mathematician, representation.name);
                    context.SaveChanges();
                }

                return(Created(
                           Url.GetMathematician(mathematician.Unique),
                           CreateRepresentation(mathematician)));
            }
        }
Ejemplo n.º 7
0
 private static void SetName(Mathematician mathematician, NameRepresentation name)
 {
     mathematician.SetName(
         name.ids.Select(s => s.FromBase64String()),
         name.firstName,
         name.lastName);
 }
 public static MathematicianRepresentation FromEntity(Mathematician mathematician)
 {
     return(new MathematicianRepresentation
     {
         unique = mathematician.Unique.ToString(),
         name = NameRepresentation.FromEntities(mathematician.CurrentNames)
     });
 }
Ejemplo n.º 9
0
        private MathematicianRepresentation CreateRepresentation(Mathematician mathematician)
        {
            var representation = MathematicianRepresentation.FromEntity(mathematician);

            representation._links = new Dictionary <string, LinkReference>
            {
                ["self"] = new LinkReference
                {
                    href = Url.GetMathematician(mathematician.Unique)
                }
            };
            return(representation);
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            Einstein += ParamMath.Add;
            Einstein += ParamMath.Subtract;
            Einstein += ParamMath.Multiply;
            Einstein += ParamMath.Divide;
            Einstein += ParamMath.Mod;

            GetNumbers();
            Einstein(ConvertToStringArray());
            Console.Write("Press Any Key To Return...");
            Console.ReadLine();
        }
Ejemplo n.º 11
0
 public IHttpActionResult GetNewMathematician()
 {
     return(Ok(CreateRepresentation(Mathematician.Create(Guid.NewGuid()))));
 }