Esempio n. 1
0
        // GET: Currencies/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Currency currency = CurrencyRepository.Find(id.Value);

            if (currency == null)
            {
                return(HttpNotFound());
            }
            return(View(currency));
        }
        public void Find_Returns_Sorted_FoundByIsoCode()
        {
            var data = new List <Currency>
            {
                new Currency {
                    IsoCode = "CC", Name = "UUU"
                },
                new Currency {
                    IsoCode = "BB", Name = "XXX"
                },
                new Currency {
                    IsoCode = "DD", Name = "YYY"
                },
                new Currency {
                    IsoCode = "AA", Name = "YYY"
                },
            };

            var mockSet     = new Mock <DbSet <Currency> >().SetupData(data);
            var mockContext = new Mock <CountryContext>();

            mockContext.Setup(c => c.Currencies).Returns(mockSet.Object);

            var service = new CurrencyRepository(mockContext.Object);

            // Act
            var items = service.Find(new string[] { "BB", "CC" }).ToList();

            Assert.IsNotNull(items);
            Assert.AreEqual(items.Count, 2);
            Assert.AreEqual(items[0].IsoCode, "BB");
            Assert.AreEqual(items[1].IsoCode, "CC");
        }