Ejemplo n.º 1
0
        public void TestThatCreateUpdateCommandReturnsSqlCommandForUpdate(bool hasDescription)
        {
            Guid         identifier            = Guid.NewGuid();
            Guid         householdIdentifier   = Guid.NewGuid();
            IHousehold   householdMock         = DomainObjectMockBuilder.BuildHouseholdMock(householdIdentifier);
            int          sortOrder             = GetLegalSortOrder();
            Guid         storageTypeIdentifier = Guid.NewGuid();
            IStorageType storageTypeMock       = DomainObjectMockBuilder.BuildStorageTypeMock(storageTypeIdentifier);
            int          temperature           = GetLegalTemperature(storageTypeMock.TemperatureRange);
            DateTime     creationTime          = DateTime.Now;
            string       description           = hasDescription ? _fixture.Create <string>() : null;

            IStorageProxy sut = CreateSut(identifier, householdMock, sortOrder, storageTypeMock, temperature, creationTime, description);

            Assert.That(sut, Is.Not.Null);

            // ReSharper disable StringLiteralTypo
            new DbCommandTestBuilder("UPDATE Storages SET HouseholdIdentifier=@householdIdentifier,SortOrder=@sortOrder,StorageTypeIdentifier=@storageTypeIdentifier,Descr=@descr,Temperature=@temperature,CreationTime=@creationTime WHERE StorageIdentifier=@storageIdentifier")
            // ReSharper restore StringLiteralTypo
            .AddCharDataParameter("@storageIdentifier", identifier)
            .AddCharDataParameter("@householdIdentifier", householdIdentifier)
            .AddTinyIntDataParameter("@sortOrder", sortOrder, 4)
            .AddCharDataParameter("@storageTypeIdentifier", storageTypeIdentifier)
            // ReSharper disable StringLiteralTypo
            .AddVarCharDataParameter("@descr", description, 2048, true)
            // ReSharper restore StringLiteralTypo
            .AddTinyIntDataParameter("@temperature", temperature, 4)
            .AddDateTimeDataParameter("@creationTime", creationTime.ToUniversalTime())
            .Build()
            .Run(sut.CreateUpdateCommand());
        }