Ejemplo n.º 1
0
        public void ValidateBillToId_WhenBillToIdIsValidated_ReturnEmptythMsg()
        {
            string billToId = new string('A', 99);
            string msg      = BMPresenter.ValidateBillToId(billToId);

            Assert.That(msg, Is.EqualTo(string.Empty));
        }
Ejemplo n.º 2
0
        public void Initialize_WhenThereIsNoBillToIDInDB_ReturnEmptyBillToIDList()
        {
            var         sut = new BMPresenter(databaseConnection, userName, viewer);
            BMViewModel vm  = sut.Initialize();

            Assert.That(vm.BillToIdDt.Rows.Count == 0);
        }
Ejemplo n.º 3
0
        public void ValidateBillToId_WhenBillToIdIsOver100Characters_ReturnBillToIdExceedsMaximumLengthMsg()
        {
            string billToId = new string('A', 101);
            string msg      = BMPresenter.ValidateBillToId(billToId);

            Assert.That(msg, Is.EqualTo("The length of BillToID can't be over 100 characters!"));
        }
Ejemplo n.º 4
0
        public void CreateBillToID_WhenBillToIDDoesNotExist_ItShouldBeCreated()
        {
            var       sut        = new BMPresenter(databaseConnection, userName, viewer);
            string    billToId   = "123456";
            string    msg        = sut.Create(billToId);
            DataTable billToIdDt = sut.Search();

            Assert.That(msg, Is.EqualTo(string.Format("BillToID: {0} is created successfully!", billToId)));
            Assert.That(billToIdDt.Rows, Has.Count.EqualTo(1));
            databaseConnection.RunSqlCommand("truncate table BillToIDs");
        }
Ejemplo n.º 5
0
        public void Search_WhenBillToIDIsNotProvided_ReturnAllRecords()
        {
            var sut = new BMPresenter(databaseConnection, userName, viewer);

            CreateTestData();

            DataTable dt = sut.Search();

            Assert.That(dt.Rows, Has.Count.EqualTo(4));

            databaseConnection.RunSqlCommand("truncate table BillToIDs");
        }
Ejemplo n.º 6
0
        public void Search_WhenBillToIDIsProvided_ReturnOnlyTheMatchedRecords(string billToId, int expectedRecords)
        {
            var sut = new BMPresenter(databaseConnection, userName, viewer);

            CreateTestData();

            DataTable dt = sut.Search(billToId);

            Assert.That(dt.Rows, Has.Count.EqualTo(expectedRecords));

            databaseConnection.RunSqlCommand("truncate table BillToIDs");
        }
Ejemplo n.º 7
0
        public void CreateBillToID_WhenBillToIDtExists_ItShouldNotBeCreated()
        {
            var    repository = new BillToIDsRepository(databaseConnection);
            var    sut        = new BMPresenter(databaseConnection, userName, viewer);
            string billToId   = "123456";

            sut.Create(billToId);
            string msg = sut.Create(billToId);

            Assert.That(msg, Is.EqualTo(string.Format("BillToID: {0} is already existed in DB.{1}Can't create duplicate BillToID!", billToId, Environment.NewLine)));

            databaseConnection.RunSqlCommand("truncate table BillToIDs");
        }
Ejemplo n.º 8
0
        public void Initialize_WhenThereAreSomeBillToIDsInDB_ReturnNotEmptyBillToIDList()
        {
            var repository = new BillToIDsRepository(databaseConnection);
            var sut        = new BMPresenter(databaseConnection, userName, viewer);

            repository.CreateBillToID("123456", userName, DateTime.Now);
            BMViewModel vm = sut.Initialize();

            Assert.That(vm.BillToIdDt.Rows, Has.Count.GreaterThan(0));
            Assert.That(vm.BillToIdDt.Rows, Has.Count.EqualTo(1));

            databaseConnection.RunSqlCommand("truncate table BillToIDs");
        }
Ejemplo n.º 9
0
        public void Delete_WhenBillToIDIsNotMatechedInDB_NoRecordIsDeleted(string billToId)
        {
            var sut = new BMPresenter(databaseConnection, userName, viewer);

            CreateTestData();

            string    msg = sut.Delete(billToId);
            DataTable dt  = sut.Search();

            Assert.That(dt.Rows, Has.Count.EqualTo(4));

            databaseConnection.RunSqlCommand("truncate table BillToIDs");
        }
Ejemplo n.º 10
0
        public void Delete_WhenBillToIDIsMatechedInDB_DeleteTheMatchedRecord()
        {
            var sut = new BMPresenter(databaseConnection, userName, viewer);

            CreateTestData();
            string billToId = "123456";

            string    msg = sut.Delete("123456");
            DataTable dt  = sut.Search();

            Assert.That(msg, Is.EqualTo(string.Format("BillToID: {0} is deleted successfully!", billToId)));
            Assert.That(dt.Rows, Has.Count.EqualTo(3));

            databaseConnection.RunSqlCommand("truncate table BillToIDs");
        }
Ejemplo n.º 11
0
        public void ValidateBillToId_WhenBillToIdIsEmptyOrNull_ReturnBillToIdEmptyMsg(string billToId)
        {
            string msg = BMPresenter.ValidateBillToId(billToId);

            Assert.That(msg, Is.EqualTo("BillToID can't be empty!"));
        }