public void Add_Returns_DuplicateException()
        {
            var          patientId    = 100;
            Immunisation immunisation = new Immunisation()
            {
                ImmunisationId = 10,
            };
            var repository = new ImmunisationRepository();

            repository.Add(patientId, immunisation);

            Assert.ThrowsException <System.Data.Linq.DuplicateKeyException>(() => repository.Add(patientId, immunisation));
        }
        public void Merge_Returns_Success_When_NoPriorImmunisation()
        {
            var          patientId    = 100;
            Immunisation immunisation = new Immunisation()
            {
                ImmunisationId = 10,
            };
            var repository = new ImmunisationRepository();

            repository.Add(patientId, immunisation);
            repository.Remove(patientId, 10);

            List <Immunisation> immunisationsToBeMerged = new List <Immunisation>()
            {
                new Immunisation()
                {
                    ImmunisationId = 11
                },
                new Immunisation()
                {
                    ImmunisationId = 12
                }
            };

            repository.Merge(patientId, immunisationsToBeMerged);
            Assert.IsNull(repository.Get(patientId, 10));
            Assert.IsNotNull(repository.Get(patientId, 11));
            Assert.IsNotNull(repository.Get(patientId, 12));
            //Assert.ThrowsException<System.Data.Linq.DuplicateKeyException>(() => repository.Add(patientId, immunisation));
        }
        public void Add_Returns_Fail_When_NullPatientId()
        {
            Immunisation immunisation = new Immunisation();
            var          repository   = new ImmunisationRepository();

            Assert.ThrowsException <ArgumentException>(() => repository.Add(0, immunisation));
        }
        public void Merge_Returns_Success()
        {
            var patientId = 100;
            List <Immunisation> immunisations = new List <Immunisation>()
            {
                new Immunisation()
                {
                    ImmunisationId = 10
                },
                new Immunisation()
                {
                    ImmunisationId = 11
                }
            };

            var repository = new ImmunisationRepository();

            repository.Add(patientId, new Immunisation()
            {
                ImmunisationId = 12
            });

            repository.Merge(patientId, immunisations);

            Assert.IsNotNull(repository.Get(patientId, 10));
            Assert.IsNotNull(repository.Get(patientId, 11));
            Assert.IsNotNull(repository.Get(patientId, 12));
        }
        public void Add_Returns_Success_When_EmptyImmunisation()
        {
            var          patientId    = 100;
            Immunisation immunisation = new Immunisation()
            {
                ImmunisationId = 10,
            };
            var repository = new ImmunisationRepository();

            repository.Add(patientId, immunisation);

            var returnImmunisation = repository.Get(patientId, immunisation.ImmunisationId);

            Assert.IsNotNull(returnImmunisation);
        }
        public void GetTotal_Return_Data()
        {
            var patientId = 100;

            var repository = new ImmunisationRepository();

            repository.Add(100, new Immunisation()
            {
                ImmunisationId = 10, CreatedDate = DateTime.Now.AddDays(-30)
            });

            var result = repository.GetTotal(patientId, DateTime.Now);

            Assert.AreEqual(1, result);
        }
        public void Get_Returns_Success()
        {
            var patientId      = 100;
            var immunisationId = 10;

            var repository = new ImmunisationRepository();

            repository.Add(100, new Immunisation()
            {
                ImmunisationId = 10
            });

            var result = repository.Get(patientId, immunisationId);

            Assert.IsNotNull(result);
        }
        public void Remove_Return_Success()
        {
            var patientId = 100;

            var repository = new ImmunisationRepository();

            repository.Add(patientId, new Immunisation()
            {
                ImmunisationId = 10, CreatedDate = DateTime.Now.AddDays(-30)
            });

            repository.Remove(patientId, 10);

            var result = repository.GetTotal(patientId, DateTime.Now);

            Assert.AreEqual(0, result);
        }
        public void Merge_Returns_DuplicateException()
        {
            var patientId = 100;
            List <Immunisation> immunisations = new List <Immunisation>()
            {
                new Immunisation()
                {
                    ImmunisationId = 10
                },
                new Immunisation()
                {
                    ImmunisationId = 10
                }
            };

            var repository = new ImmunisationRepository();

            repository.Add(patientId, new Immunisation()
            {
                ImmunisationId = 12
            });

            Assert.ThrowsException <System.Data.Linq.DuplicateKeyException>(() => repository.Merge(patientId, immunisations));
        }
        public void Add_Returns_Fail_When_NullImmunisation()
        {
            var repository = new ImmunisationRepository();

            Assert.ThrowsException <ArgumentNullException>(() => repository.Add(10, null));
        }