예제 #1
0
        public void GetLastCheques_GetsZeroOrLessCount_ReturnEmptyList(int count)
        {
            ////Arrange
            var repo = new FakeDBRepository();

            ////Act
            var actualCheques = repo.GetLastCheques(count);

            ////Assert
            Assert.That(actualCheques, Is.Empty);
        }
예제 #2
0
        public void GetLastCheques_GetsCountofCheques_ReturnLastCheques()
        {
            ////Arrange
            var cheque = new Cheque()
            {
                Id       = new Guid(),
                Number   = "some",
                Discount = 200,
                Summ     = 2000,
                Articles = new[] { "article1", "article2", "article3" }
            };

            var dirOfXml = Path.Combine(
                Directory
                .GetParent(
                    AppDomain.CurrentDomain.BaseDirectory)
                .Parent.Parent.Parent.Parent
                .FullName,
                "TestWcf",
                "App_Data",
                "data.xml");

            var formatter = new XmlSerializer(typeof(List <Cheque>));

            var cheques = new List <Cheque>();

            using (FileStream fs = new FileStream(dirOfXml, FileMode.OpenOrCreate))
            {
                cheques = formatter.Deserialize(fs) as List <Cheque>;
            }

            cheques.Add(cheque);
            cheques.Add(cheque);
            cheques.Add(cheque);

            using (FileStream fs = new FileStream(dirOfXml, FileMode.Open))
            {
                formatter.Serialize(fs, cheques);
            }
            ////Arrange
            var repo = new FakeDBRepository();

            ////Act
            var actualCheques = repo.GetLastCheques(3);

            ////Assert
            Assert.That(actualCheques, Has.Count.EqualTo(3));
        }